From b84bf65ac40af0761fb266f35c3698856ef03077 Mon Sep 17 00:00:00 2001 From: Jean Guyader Date: Sun, 30 Aug 2009 14:46:58 +0100 Subject: [PATCH] Qemu log into syslog --- master/atapi-pass-through | 63 ++++++++++++--------------- master/ioemu-compil | 8 +++- master/qemu-log-syslog | 92 +++++++++++++++++++++++++++++++++++++++ master/series | 3 ++ master/thermal-management | 52 +++++++++++++++++----- 5 files changed, 171 insertions(+), 47 deletions(-) create mode 100644 master/qemu-log-syslog diff --git a/master/atapi-pass-through b/master/atapi-pass-through index 03144f6..9acc7b4 100644 --- a/master/atapi-pass-through +++ b/master/atapi-pass-through @@ -1,8 +1,8 @@ diff --git a/Makefile b/Makefile -index c395e77..f789785 100644 +index 5f4f4cf..42da5b6 100644 --- a/Makefile +++ b/Makefile -@@ -264,8 +264,9 @@ endif +@@ -266,8 +266,9 @@ endif test speed: all $(MAKE) -C tests $@ @@ -97,7 +97,7 @@ index 0000000..f9bdee9 +#endif /* !BLOCK_RAW_POSIX_H */ diff --git a/hw/atapi-pt.c b/hw/atapi-pt.c new file mode 100644 -index 0000000..b1c380f +index 0000000..2f63492 --- /dev/null +++ b/hw/atapi-pt.c @@ -0,0 +1,970 @@ @@ -1072,7 +1072,7 @@ index 0000000..b1c380f + } +} diff --git a/hw/ide.c b/hw/ide.c -index e8d676e..fa75de7 100644 +index e8d676e..85a2813 100644 --- a/hw/ide.c +++ b/hw/ide.c @@ -22,6 +22,7 @@ @@ -1350,16 +1350,7 @@ index e8d676e..fa75de7 100644 /* ATA DMA state */ int io_buffer_size; QEMUSGList sg; -@@ -940,6 +998,8 @@ static inline void ide_set_irq(IDEState *s) - if (bm) { - bm->status |= BM_STATUS_INT; - } -+ if (s->is_cdrom) -+ puts("@@@@@@@@ CDROM IRQ"); - qemu_irq_raise(s->irq); - } - } -@@ -1321,9 +1381,9 @@ static void ide_sector_write(IDEState *s) +@@ -1321,9 +1379,9 @@ static void ide_sector_write(IDEState *s) that at the expense of slower write performances. Use this option _only_ to install Windows 2000. You must disable it for normal use. */ @@ -1371,7 +1362,7 @@ index e8d676e..fa75de7 100644 #endif { ide_set_irq(s); -@@ -1499,6 +1559,13 @@ static inline int ube16_to_cpu(const uint8_t *buf) +@@ -1499,6 +1557,13 @@ static inline int ube16_to_cpu(const uint8_t *buf) return (buf[0] << 8) | buf[1]; } @@ -1385,7 +1376,7 @@ index e8d676e..fa75de7 100644 static inline int ube32_to_cpu(const uint8_t *buf) { return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; -@@ -1567,12 +1634,14 @@ static void ide_atapi_io_error(IDEState *s, int ret) +@@ -1567,12 +1632,14 @@ static void ide_atapi_io_error(IDEState *s, int ret) static void ide_atapi_cmd_reply_end(IDEState *s) { int byte_count_limit, size, ret; @@ -1400,7 +1391,7 @@ index e8d676e..fa75de7 100644 if (s->packet_transfer_size <= 0) { /* end of transfer */ ide_transfer_stop(s); -@@ -1582,63 +1651,65 @@ static void ide_atapi_cmd_reply_end(IDEState *s) +@@ -1582,63 +1649,65 @@ static void ide_atapi_cmd_reply_end(IDEState *s) #ifdef DEBUG_IDE_ATAPI printf("status=0x%x\n", s->status); #endif @@ -1517,7 +1508,7 @@ index e8d676e..fa75de7 100644 } } -@@ -1882,6 +1953,10 @@ static int ide_dvd_read_structure(IDEState *s, int format, +@@ -1882,6 +1951,10 @@ static int ide_dvd_read_structure(IDEState *s, int format, } } @@ -1528,7 +1519,7 @@ index e8d676e..fa75de7 100644 static void ide_atapi_cmd(IDEState *s) { const uint8_t *packet; -@@ -1922,7 +1997,6 @@ static void ide_atapi_cmd(IDEState *s) +@@ -1922,7 +1995,6 @@ static void ide_atapi_cmd(IDEState *s) ASC_MEDIUM_NOT_PRESENT); } break; @@ -1536,7 +1527,7 @@ index e8d676e..fa75de7 100644 case GPCMD_MODE_SENSE_10: { int action, code; -@@ -1935,9 +2009,9 @@ static void ide_atapi_cmd(IDEState *s) +@@ -1935,9 +2007,9 @@ static void ide_atapi_cmd(IDEState *s) switch(action) { case 0: /* current values */ switch(code) { @@ -1548,7 +1539,7 @@ index e8d676e..fa75de7 100644 buf[3] = 0; buf[4] = 0; buf[5] = 0; -@@ -1954,17 +2028,17 @@ static void ide_atapi_cmd(IDEState *s) +@@ -1954,17 +2026,17 @@ static void ide_atapi_cmd(IDEState *s) buf[15] = 0x00; ide_atapi_cmd_reply(s, 16, max_len); break; @@ -1570,7 +1561,7 @@ index e8d676e..fa75de7 100644 buf[10] = 0x00; buf[11] = 0x00; -@@ -1987,6 +2061,7 @@ static void ide_atapi_cmd(IDEState *s) +@@ -1987,6 +2059,7 @@ static void ide_atapi_cmd(IDEState *s) buf[27] = 0; ide_atapi_cmd_reply(s, 28, max_len); break; @@ -1578,7 +1569,7 @@ index e8d676e..fa75de7 100644 default: goto error_cmd; } -@@ -2110,7 +2185,7 @@ static void ide_atapi_cmd(IDEState *s) +@@ -2110,7 +2183,7 @@ static void ide_atapi_cmd(IDEState *s) break; case GPCMD_MECHANISM_STATUS: { @@ -1587,7 +1578,7 @@ index e8d676e..fa75de7 100644 cpu_to_ube16(buf, 0); /* no current LBA */ buf[2] = 0; -@@ -2125,7 +2200,6 @@ static void ide_atapi_cmd(IDEState *s) +@@ -2125,7 +2198,6 @@ static void ide_atapi_cmd(IDEState *s) { int format, msf, start_track, len; uint64_t total_sectors; @@ -1595,7 +1586,7 @@ index e8d676e..fa75de7 100644 bdrv_get_geometry(s->bs, &total_sectors); total_sectors >>= 2; if (total_sectors == 0) { -@@ -2279,7 +2353,7 @@ static void ide_atapi_cmd(IDEState *s) +@@ -2279,7 +2351,7 @@ static void ide_atapi_cmd(IDEState *s) max_len = 512; memset(buf, 0, max_len); @@ -1604,7 +1595,7 @@ index e8d676e..fa75de7 100644 * the number of sectors from the media tells us which profile * to use as current. 0 means there is no media */ -@@ -2484,7 +2558,11 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) +@@ -2484,7 +2556,11 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) /* Only DEVICE RESET is allowed while BSY or/and DRQ are set */ if ((s->status & (BUSY_STAT|DRQ_STAT)) && val != WIN_DEVICE_RESET) @@ -1616,7 +1607,7 @@ index e8d676e..fa75de7 100644 switch(val) { case WIN_IDENTIFY: -@@ -2727,7 +2805,7 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) +@@ -2727,7 +2803,7 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) else s->status = READY_STAT | SEEK_STAT; s->error = 0x01; /* Device 0 passed, Device 1 passed or not @@ -1625,7 +1616,7 @@ index e8d676e..fa75de7 100644 */ ide_set_irq(s); break; -@@ -2748,7 +2826,7 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) +@@ -2748,7 +2824,7 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) s->atapi_dma = s->feature & 1; s->nsector = 1; ide_transfer_start(s, s->io_buffer, ATAPI_PACKET_SIZE, @@ -1634,7 +1625,7 @@ index e8d676e..fa75de7 100644 break; /* CF-ATA commands */ case CFA_REQ_EXT_ERROR_CODE: -@@ -3133,8 +3211,20 @@ static void ide_init2(IDEState *ide_state, +@@ -3133,8 +3209,20 @@ static void ide_init2(IDEState *ide_state, if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) { s->is_cdrom = 1; @@ -1656,10 +1647,10 @@ index e8d676e..fa75de7 100644 s->drive_serial = drive_serial++; strncpy(s->drive_serial_str, drive_get_serial(s->bs), diff --git a/vl.c b/vl.c -index 7b925eb..f7b696d 100644 +index f3b0dae..91fb696 100644 --- a/vl.c +++ b/vl.c -@@ -2193,8 +2193,10 @@ static int bt_parse(const char *opt) +@@ -2192,8 +2192,10 @@ static int bt_parse(const char *opt) #define HD_ALIAS "index=%d,media=disk" #ifdef TARGET_PPC #define CDROM_ALIAS "index=1,media=cdrom" @@ -1670,7 +1661,7 @@ index 7b925eb..f7b696d 100644 #endif #define FD_ALIAS "index=%d,if=floppy" #define PFLASH_ALIAS "if=pflash" -@@ -2332,7 +2334,7 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) +@@ -2331,7 +2333,7 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) char serial[21]; const char *mediastr = ""; BlockInterfaceType type; @@ -1679,7 +1670,7 @@ index 7b925eb..f7b696d 100644 int bus_id, unit_id; int cyls, heads, secs, translation; BlockDriverState *bdrv; -@@ -2486,6 +2488,8 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) +@@ -2485,6 +2487,8 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) return -1; } media = MEDIA_CDROM; @@ -1688,7 +1679,7 @@ index 7b925eb..f7b696d 100644 } else { fprintf(stderr, "qemu: '%s' invalid media\n", str); return -1; -@@ -2640,6 +2644,9 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) +@@ -2639,6 +2643,9 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) case MEDIA_CDROM: bdrv_set_type_hint(bdrv, BDRV_TYPE_CDROM); break; @@ -1698,7 +1689,7 @@ index 7b925eb..f7b696d 100644 } break; case IF_SD: -@@ -4243,6 +4250,7 @@ enum { +@@ -4244,6 +4251,7 @@ enum { QEMU_OPTION_hdc, QEMU_OPTION_hdd, QEMU_OPTION_cdrom, @@ -1714,7 +1705,7 @@ index 7b925eb..f7b696d 100644 { "drive", HAS_ARG, QEMU_OPTION_drive }, { "mtdblock", HAS_ARG, QEMU_OPTION_mtdblock }, { "sd", HAS_ARG, QEMU_OPTION_sd }, -@@ -5036,13 +5045,16 @@ int main(int argc, char **argv, char **envp) +@@ -5035,13 +5044,16 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_cdrom: drive_add(optarg, CDROM_ALIAS); break; diff --git a/master/ioemu-compil b/master/ioemu-compil index e303c9e..66517cb 100644 --- a/master/ioemu-compil +++ b/master/ioemu-compil @@ -1,5 +1,5 @@ diff --git a/xen-hooks.mak b/xen-hooks.mak -index c6b4f8c..d2f09fb 100644 +index c6b4f8c..7c22471 100644 --- a/xen-hooks.mak +++ b/xen-hooks.mak @@ -52,7 +52,7 @@ endif @@ -21,6 +21,12 @@ index c6b4f8c..d2f09fb 100644 LIBS += -lpci CFLAGS += -DCONFIG_PASSTHROUGH $(info === PCI passthrough capability has been enabled ===) +@@ -79,3 +82,5 @@ docdir := $(subst qemu,xen/qemu,$(docdir)) + mandir := $(subst share/man,share/xen/man,$(mandir)) + + configdir := /etc/xen ++ ++TOOLS = diff --git a/xen-setup b/xen-setup index 8ca0019..f74a09e 100755 --- a/xen-setup diff --git a/master/qemu-log-syslog b/master/qemu-log-syslog new file mode 100644 index 0000000..b5f98f1 --- /dev/null +++ b/master/qemu-log-syslog @@ -0,0 +1,92 @@ +diff -r fe4c575ded12 Makefile +--- a/Makefile Mon Jun 15 17:17:13 2009 +0100 ++++ b/Makefile Mon Jun 15 17:33:03 2009 +0100 +@@ -10,6 +10,7 @@ + + + CFLAGS += $(OS_CFLAGS) $(ARCH_CFLAGS) ++CFLAGS+=-Dfprintf=__syslog_fprintf + LDFLAGS += $(OS_LDFLAGS) $(ARCH_LDFLAGS) + + CPPFLAGS += -I. -I$(SRC_PATH) -MMD -MP -MT $@ +@@ -92,6 +93,7 @@ + OBJS+=bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o usb-bt.o + OBJS+=buffered_file.o migration.o migration-tcp.o net.o qemu-sockets.o + OBJS+=qemu-char.o aio.o net-checksum.o savevm.o cache-utils.o ++OBJS+=logging.o + + ifdef CONFIG_BRLAPI + OBJS+= baum.o +diff -r fe4c575ded12 Makefile.target +--- a/Makefile.target Mon Jun 15 17:17:13 2009 +0100 ++++ b/Makefile.target Mon Jun 15 17:33:03 2009 +0100 +@@ -79,6 +79,8 @@ + > /dev/null 2>&1; then echo "$(2)"; else echo "$(3)"; fi ;) + + HELPER_CFLAGS= ++ ++CFLAGS+=-Dfprintf=__syslog_fprintf + + ifeq ($(ARCH),i386) + HELPER_CFLAGS+=-fomit-frame-pointer +diff -r fe4c575ded12 logging.c +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/logging.c Mon Jun 15 17:33:03 2009 +0100 +@@ -0,0 +1,19 @@ ++#include "logging.h" ++ ++void cpu_set_log_syslog(const char *ident) ++{ ++ closelog(); ++ openlog(ident, LOG_NOWAIT | LOG_PID, LOG_DAEMON); ++} ++ ++int __syslog_fprintf(FILE *stream, const char *format, ...) ++{ ++ va_list ap; ++ ++ va_start(ap, format); ++ vsyslog(LOG_DAEMON | LOG_NOTICE, format, ap); ++ va_end(ap); ++ ++ return 0; ++} ++ +diff -r fe4c575ded12 logging.h +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/logging.h Mon Jun 15 17:33:03 2009 +0100 +@@ -0,0 +1,11 @@ ++#ifndef QEMU_LOGGING_H ++#define QEMU_LOGGING_H ++ ++#include ++#include ++#include ++ ++void cpu_set_log_syslog(const char *ident); ++ ++#endif ++ +diff -r fe4c575ded12 qemu-common.h +--- a/qemu-common.h Mon Jun 15 17:17:13 2009 +0100 ++++ b/qemu-common.h Mon Jun 15 17:33:03 2009 +0100 +@@ -31,6 +31,7 @@ + #include + #include + #include "config-host.h" ++#include "logging.h" + + #ifndef O_LARGEFILE + #define O_LARGEFILE 0 +diff -r fe4c575ded12 vl.c +--- a/vl.c Mon Jun 15 17:17:13 2009 +0100 ++++ b/vl.c Mon Jun 15 17:33:03 2009 +0100 +@@ -5391,6 +5391,8 @@ + snprintf(domain_name, sizeof(domain_name), + "Xen-%s", optarg); + qemu_name = optarg; ++ cpu_set_log_syslog(domain_name); ++ cpu_set_log(0); + break; + #if defined(TARGET_SPARC) || defined(TARGET_PPC) + case QEMU_OPTION_prom_env: diff --git a/master/series b/master/series index 5d6fad1..33136ca 100644 --- a/master/series +++ b/master/series @@ -1,3 +1,6 @@ + +qemu-log-syslog + ioemu-compil add-config-audio xenstore-watch-callbacks diff --git a/master/thermal-management b/master/thermal-management index 47e74bc..1d167ba 100644 --- a/master/thermal-management +++ b/master/thermal-management @@ -1,5 +1,5 @@ diff --git a/hw/piix4acpi.c b/hw/piix4acpi.c -index cf214a4..edede92 100644 +index 3803824..4e0410b 100644 --- a/hw/piix4acpi.c +++ b/hw/piix4acpi.c @@ -30,6 +30,7 @@ @@ -18,6 +18,38 @@ index cf214a4..edede92 100644 } static inline int test_bit(uint8_t *map, int bit) +@@ -283,8 +285,8 @@ static void acpi_dbg_writel(void *opaque, uint32_t addr, uint32_t val) + { + #if defined(DEBUG) + printf("ACPI: DBG: 0x%08x\n", val); +-#endif + fprintf(logfile, "ACPI:debug: write addr=0x%x, val=0x%x.\n", addr, val); ++#endif + } + + /* +@@ -315,8 +317,10 @@ static uint32_t acpi_php_readb(void *opaque, uint32_t addr) + val = hotplug_slots->status[num]; + } + ++#if defined(DEBUG) + fprintf(logfile, "ACPI PCI hotplug: read addr=0x%x, val=0x%x.\n", + addr, val); ++#endif + + return val; + } +@@ -326,8 +330,10 @@ static void acpi_php_writeb(void *opaque, uint32_t addr, uint32_t val) + PHPSlots *hotplug_slots = opaque; + int slot; + ++#if defined(DEBUG) + fprintf(logfile, "ACPI PCI hotplug: write addr=0x%x, val=0x%x.\n", + addr, val); ++#endif + + switch (addr) + { diff --git a/hw/thermal_mgmt.c b/hw/thermal_mgmt.c new file mode 100644 index 0000000..649b622 @@ -145,10 +177,10 @@ index 0000000..d83273b +#endif + diff --git a/qemu-xen.h b/qemu-xen.h -index 60ee108..0cc5dd8 100644 +index 6dac050..7883718 100644 --- a/qemu-xen.h +++ b/qemu-xen.h -@@ -125,9 +125,12 @@ char *xenstore_device_model_read(int domid, const char *key, unsigned int *len); +@@ -127,9 +127,12 @@ char *xenstore_device_model_read(int domid, const char *key, unsigned int *len); int xenstore_extended_power_mgmt_read_int(const char *key, int default_value); char *xenstore_read_battery_data(int battery_status); int xenstore_refresh_battery_status(void); @@ -162,7 +194,7 @@ index 60ee108..0cc5dd8 100644 int xenstore_pv_driver_build_blacklisted(uint16_t product_number, uint32_t build_nr); diff --git a/xen-hooks.mak b/xen-hooks.mak -index 03d670e..7c94718 100644 +index 6fd75cf..799f80d 100644 --- a/xen-hooks.mak +++ b/xen-hooks.mak @@ -36,6 +36,7 @@ OBJS += pci_emulation.o @@ -171,13 +203,13 @@ index 03d670e..7c94718 100644 OBJS += xen_acpi_wmi.o +OBJS += thermal_mgmt.o - ifdef CONFIG_STUBDOM - CPPFLAGS += $(TARGET_CPPFLAGS) -DNEED_CPU_H \ + CONFIG_AUDIO=1 + diff --git a/xenstore.c b/xenstore.c -index 7cd4d54..01afcf0 100644 +index 9fc79f4..3cd2ba6 100644 --- a/xenstore.c +++ b/xenstore.c -@@ -1464,6 +1464,11 @@ int xenstore_refresh_battery_status(void) +@@ -1465,6 +1465,11 @@ int xenstore_refresh_battery_status(void) return xenstore_extended_power_mgmt_event_trigger("refreshbatterystatus", "1"); } @@ -188,8 +220,8 @@ index 7cd4d54..01afcf0 100644 + void xenstore_register_for_pm_events(void) { - xs_watch(xsh, "/pm/events/acadapterstatechanged", "acadapterstatechangeevt"); -@@ -1487,6 +1492,16 @@ int xenstore_read_lid_state(void) + char *inject_sci_buffer; +@@ -1501,6 +1506,16 @@ int xenstore_read_lid_state(void) return xenstore_extended_power_mgmt_read_int("lid_state", 1); } -- 2.39.5