diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index b128d311c27b779f53ff6c028c6aced13789a575..8a98446b7c74131dcaeb14bad67b30b8378c1c23 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1751,7 +1751,10 @@ void kvm_irqchip_commit_routes(KVMState *s) s->irq_routes->flags = 0; trace_kvm_irqchip_commit_routes(); ret = kvm_vm_ioctl(s, KVM_SET_GSI_ROUTING, s->irq_routes); - assert(ret == 0); + if (ret < 0) { + error_report("Set GSI routing failed: %m"); + abort(); + } } static void kvm_add_routing_entry(KVMState *s, diff --git a/hw/acpi/core.c b/hw/acpi/core.c index 1e004d0078d506147536b6ad6512af054fb70147..eb631caa91c8600533cefed84c2ff9fa8473454d 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -24,6 +24,7 @@ #include "hw/acpi/acpi.h" #include "hw/nvram/fw_cfg.h" #include "qemu/config-file.h" +#include "qemu/log.h" #include "qapi/error.h" #include "qapi/opts-visitor.h" #include "qapi/qapi-events-run-state.h" @@ -560,13 +561,16 @@ static void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val) uint16_t sus_typ = (val >> 10) & 7; switch (sus_typ) { case 0: /* soft power off */ + qemu_log("VM will be soft power off\n"); qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); break; case 1: + qemu_log("VM will be suspend state\n"); qemu_system_suspend_request(); break; default: if (sus_typ == ar->pm1.cnt.s4_val) { /* S4 request */ + qemu_log("VM will be S4 state\n"); qapi_event_send_suspend_disk(); qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); } diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 74ad397b1ff907b11dd226c81b3289cc6aafbb30..21024f79991bf1b35ea8f6788485b469568f006f 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -12,6 +12,7 @@ #include "qemu/datadir.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "qemu/log.h" #include #include "hw/arm/boot.h" #include "hw/arm/linux-boot-if.h" @@ -1317,6 +1318,9 @@ void arm_load_kernel(ARMCPU *cpu, MachineState *ms, struct arm_boot_info *info) * doesn't support secure. */ assert(!(info->secure_board_setup && kvm_enabled())); + + qemu_log("load the kernel\n"); + info->kernel_filename = ms->kernel_filename; info->kernel_cmdline = ms->kernel_cmdline; info->initrd_filename = ms->initrd_filename; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 0538d258fae9039c5795607f1989dbac57daa7ac..47e98f09e83026b8bb313d06bafd439bdd4dfd55 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -33,6 +33,7 @@ #include "qemu/datadir.h" #include "qemu/units.h" #include "qemu/option.h" +#include "qemu/log.h" #include "monitor/qdev.h" #include "qapi/error.h" #include "hw/sysbus.h" @@ -971,6 +972,7 @@ static void virt_powerdown_req(Notifier *n, void *opaque) { VirtMachineState *s = container_of(n, VirtMachineState, powerdown_notifier); + qemu_log("send powerdown to vm.\n"); if (s->acpi_dev) { acpi_send_event(s->acpi_dev, ACPI_POWER_DOWN_STATUS); } else { @@ -2072,6 +2074,7 @@ static void machvirt_init(MachineState *machine) } create_fdt(vms); + qemu_log("cpu init start\n"); possible_cpus = mc->possible_cpu_arch_ids(machine); assert(possible_cpus->len == max_cpus); diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index f01ec2137c95abcfa7fcf0efcef9e5d3ca792153..edb7a44ee9d9d7de18dca1b6b4460c455d14413c 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -257,6 +257,8 @@ static size_t send_control_event(VirtIOSerial *vser, uint32_t port_id, virtio_stw_p(vdev, &cpkt.value, value); trace_virtio_serial_send_control_event(port_id, event, value); + qemu_log("virtio serial port %d send control message" + " event = %d, value = %d\n", port_id, event, value); return send_control_msg(vser, &cpkt, sizeof(cpkt)); } @@ -364,6 +366,9 @@ static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len) cpkt.value = virtio_lduw_p(vdev, &gcpkt->value); trace_virtio_serial_handle_control_message(cpkt.event, cpkt.value); + qemu_log("virtio serial port '%u' handle control message" + " event = %d, value = %d\n", + virtio_ldl_p(vdev, &gcpkt->id), cpkt.event, cpkt.value); if (cpkt.event == VIRTIO_CONSOLE_DEVICE_READY) { if (!cpkt.value) { diff --git a/hw/core/reset.c b/hw/core/reset.c index 9c477f2bf5bdc4adb97b32e92d6493083cd4c969..e923723d38fa45ae39a7da631f1adf53be8adba4 100644 --- a/hw/core/reset.c +++ b/hw/core/reset.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "qemu/queue.h" +#include "qemu/log.h" #include "sysemu/reset.h" /* reset/shutdown handler */ @@ -64,6 +65,7 @@ void qemu_devices_reset(void) { QEMUResetEntry *re, *nre; + qemu_log("reset all devices\n"); /* reset all devices */ QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) { re->func(re->opaque); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e5993c1ef52b7c9e39faa7de4020ab5898aef0a3..8b182fbb0cb00a92fc86b966f0a5693e0577ee64 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2408,6 +2408,7 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom, } else { snprintf(name, sizeof(name), "%s.rom", object_get_typename(OBJECT(pdev))); } + qemu_log("add rom file: %s\n", name); pdev->has_rom = true; memory_region_init_rom(&pdev->rom, OBJECT(pdev), name, pdev->romsize, &error_fatal); ptr = memory_region_get_ram_ptr(&pdev->rom); diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 92d6ed5626141f8622c55bedb9dc23326b3338c8..20cd9b6e6fd9e70689bfe756ff44a2ff8a013fca 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -536,6 +536,10 @@ void usb_check_attach(USBDevice *dev, Error **errp) bus->qbus.name, port->path, portspeed); return; } + + qemu_log("attach usb device \"%s\" (%s speed) to VM bus \"%s\", " + "port \"%s\" (%s speed)\n", dev->product_desc, devspeed, + bus->qbus.name, port->path, portspeed); } void usb_device_attach(USBDevice *dev, Error **errp) @@ -564,6 +568,8 @@ int usb_device_detach(USBDevice *dev) usb_detach(port); dev->attached = false; + qemu_log("detach usb device \"%s\" from VM bus \"%s\", port \"%s\"\n", + dev->product_desc, bus->qbus.name, port->path); return 0; } diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 8f521ad586ad251925992ca230bfc6c7b81541b4..3394b04f509104c209fc521591b3beb047481284 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -992,6 +992,8 @@ static int usb_host_open(USBHostDevice *s, libusb_device *dev, int hostfd) rc = libusb_open(dev, &s->dh); if (rc != 0) { + qemu_log("libusb open usb device bus %d, device %d failed\n", + bus_num, addr); goto fail; } } else { @@ -1019,6 +1021,7 @@ static int usb_host_open(USBHostDevice *s, libusb_device *dev, int hostfd) libusb_get_device_descriptor(dev, &s->ddesc); usb_host_get_port(s->dev, s->port, sizeof(s->port)); + qemu_log("open a host usb device on bus %d, device %d\n", bus_num, addr); usb_ep_init(udev); usb_host_ep_update(s); @@ -1146,6 +1149,8 @@ static int usb_host_close(USBHostDevice *s) usb_device_detach(udev); } + qemu_log("begin to reset the usb device, bus : %d, device : %d\n", + s->bus_num, s->addr); usb_host_release_interfaces(s); libusb_reset_device(s->dh); usb_host_attach_kernel(s); diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 750aa47ec148267f36ee0d6672cb68b5c5e7fdf2..90e30bc11c7ff9f646b6bb7e640884a31746c2f8 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1772,7 +1772,9 @@ static void virtio_pci_device_unplugged(DeviceState *d) VirtIOPCIProxy *proxy = VIRTIO_PCI(d); bool modern = virtio_pci_modern(proxy); bool modern_pio = proxy->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY; + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); + qemu_log("device name: %s\n", !vdev ? "NULL" : vdev->name); virtio_pci_stop_ioeventfd(proxy); if (modern) { diff --git a/hw/virtio/virtio-scsi-pci.c b/hw/virtio/virtio-scsi-pci.c index 97fab742368ac4c4332e4f3f6f1da1153468f488..498f9e2c984ccb996694c1390f766cdfc9e514d0 100644 --- a/hw/virtio/virtio-scsi-pci.c +++ b/hw/virtio/virtio-scsi-pci.c @@ -18,6 +18,7 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-scsi.h" #include "qemu/module.h" +#include "qemu/log.h" #include "virtio-pci.h" #include "qom/object.h" @@ -51,6 +52,8 @@ static void virtio_scsi_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) VirtIOSCSIConf *conf = &dev->vdev.parent_obj.conf; char *bus_name; + qemu_log("virtio scsi HBA %s begin to initialize.\n", + !proxy->id ? "NULL" : proxy->id); if (conf->num_queues == VIRTIO_SCSI_AUTO_NUM_QUEUES) { conf->num_queues = virtio_pci_optimal_num_queues(VIRTIO_SCSI_VQ_NUM_FIXED); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index ea7c079fb046b0a339e86e68c66ff4f787a541fd..9f4f1095b44c3ae563721f14f3cb2f22f93791b8 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1945,6 +1945,13 @@ int virtio_set_status(VirtIODevice *vdev, uint8_t val) k->set_status(vdev, val); } vdev->status = val; + if (val) { + qemu_log("%s device status is %d that means %s\n", vdev->name, val, + (val & VIRTIO_CONFIG_S_DRIVER_OK) ? "DRIVER OK" : + (val & VIRTIO_CONFIG_S_DRIVER) ? "DRIVER" : + (val & VIRTIO_CONFIG_S_ACKNOWLEDGE) ? "ACKNOWLEDGE" : + (val & VIRTIO_CONFIG_S_FAILED) ? "FAILED" : "UNKNOWN"); + } return 0; } @@ -2389,8 +2396,10 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size, break; } - if (i == VIRTIO_QUEUE_MAX || queue_size > VIRTQUEUE_MAX_SIZE) + if (i == VIRTIO_QUEUE_MAX || queue_size > VIRTQUEUE_MAX_SIZE) { + qemu_log("unacceptable queue_size (%d) or num (%d)\n", queue_size, i); abort(); + } vdev->vq[i].vring.num = queue_size; vdev->vq[i].vring.num_default = queue_size; diff --git a/monitor/monitor.c b/monitor/monitor.c index 21c7a68758f552cfe17cfcf7d5c946b19e112c93..5831495ad52e8ce40100ba7cc4eb800823ac37b4 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -23,12 +23,14 @@ */ #include "qemu/osdep.h" +#include "qemu/log.h" #include "monitor-internal.h" #include "qapi/error.h" #include "qapi/opts-visitor.h" #include "qapi/qapi-emit-events.h" #include "qapi/qapi-visit-control.h" #include "qapi/qmp/qdict.h" +#include "qapi/qmp/qjson.h" #include "qemu/error-report.h" #include "qemu/option.h" #include "sysemu/qtest.h" @@ -318,6 +320,7 @@ static void monitor_qapi_event_emit(QAPIEvent event, QDict *qdict) { Monitor *mon; MonitorQMP *qmp_mon; + GString *json; trace_monitor_protocol_event_emit(event, qdict); QTAILQ_FOREACH(mon, &mon_list, entry) { @@ -328,6 +331,13 @@ static void monitor_qapi_event_emit(QAPIEvent event, QDict *qdict) qmp_mon = container_of(mon, MonitorQMP, common); if (qmp_mon->commands != &qmp_cap_negotiation_commands) { qmp_send_response(qmp_mon, qdict); + json = qobject_to_json(QOBJECT(qdict)); + if (json) { + if (!strstr(json->str, "RTC_CHANGE")) { + qemu_log("%s\n", json->str); + } + g_string_free(json, true); + } } } } diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 98868cee03fbc3de9696ab3692e05730fb925168..d71beace6ad2c9baaf71095e36bed36a0ef4d434 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -21,6 +21,7 @@ #include "sysemu/sysemu.h" #include "qemu/config-file.h" #include "qemu/uuid.h" +#include "qemu/log.h" #include "chardev/char.h" #include "ui/qemu-spice.h" #include "ui/console.h" @@ -150,8 +151,10 @@ void qmp_cont(Error **errp) } if (runstate_check(RUN_STATE_INMIGRATE)) { + qemu_log("qmp cont is received in migration\n"); autostart = 1; } else { + qemu_log("qmp cont is received and vm is started\n"); vm_start(); } } diff --git a/os-posix.c b/os-posix.c index ae6c9f2a5e983772745067ea9db74ac44b93f9ac..306c442bc87c6ab87ba5fcbfbae00d76650aac71 100644 --- a/os-posix.c +++ b/os-posix.c @@ -322,6 +322,7 @@ int os_mlock(void) #ifdef HAVE_MLOCKALL int ret = 0; + qemu_log("do mlockall\n"); ret = mlockall(MCL_CURRENT | MCL_FUTURE); if (ret < 0) { error_report("mlockall: %s", strerror(errno)); diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index d378bccac73b4886f8ba1b9e5b14e50fc6a80dd3..082b8074522215d6f33dfef6e8738ebdcca151a8 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -25,6 +25,8 @@ #include "qapi/qmp/qbool.h" #include "qemu/coroutine.h" #include "qemu/main-loop.h" +#include "qemu/log.h" +#include "qapi/qmp/qstring.h" Visitor *qobject_input_visitor_new_qmp(QObject *obj) { @@ -145,6 +147,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request, const QmpCommand *cmd; QDict *dict; QObject *id; + GString *json; QObject *ret = NULL; QDict *rsp = NULL; @@ -206,6 +209,20 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request, assert(!(oob && qemu_in_coroutine())); assert(monitor_cur() == NULL); + + json = qobject_to_json(QOBJECT(args)); + if (json) { + if ((strcmp(command, "query-block-jobs") != 0) + && (strcmp(command, "query-migrate") != 0) + && (strcmp(command, "query-blockstats") != 0) + && (strcmp(command, "query-balloon") != 0) + && (strcmp(command, "set_password") != 0)) { + qemu_log("qmp_cmd_name: %s, arguments: %s\n", + command, json->str); + } + g_string_free(json, true); + } + if (!!(cmd->options & QCO_COROUTINE) == qemu_in_coroutine()) { monitor_set_cur(qemu_coroutine_self(), cur_mon); cmd->fn(args, &ret, &err); diff --git a/softmmu/main.c b/softmmu/main.c index 639c67ff489356d51534d16665d7a4cf46414b5f..0acb41bd300dc261b639b8d3752f50d4ee2f9eb2 100644 --- a/softmmu/main.c +++ b/softmmu/main.c @@ -23,6 +23,7 @@ */ #include "qemu/osdep.h" +#include "qemu/log.h" #include "qemu-common.h" #include "sysemu/sysemu.h" @@ -47,6 +48,7 @@ int main(int argc, char **argv) int main(int argc, char **argv, char **envp) { qemu_init(argc, argv, envp); + qemu_log("qemu enter main_loop\n"); qemu_main_loop(); qemu_cleanup(); diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 01f3834db575a6932c8e292068d4ab71125abe45..f21c061ac91467280cd30af7463b54f1589d8f40 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -36,6 +36,7 @@ #include "qemu/option.h" #include "qemu/qemu-print.h" #include "qemu/option_int.h" +#include "qemu/log.h" #include "sysemu/block-backend.h" #include "migration/misc.h" #include "migration/migration.h" @@ -635,6 +636,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts, if (path != NULL) { bus = qbus_find(path, errp); if (!bus) { + qemu_log("can not find bus for %s\n", driver); return NULL; } if (!object_dynamic_cast(OBJECT(bus), dc->bus_type)) { @@ -705,6 +707,8 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts, object_set_properties_from_keyval(&dev->parent_obj, dev->opts, from_json, errp); if (*errp) { + qemu_log("the bus %s -driver %s set property failed\n", + bus ? bus->name : "None", driver); goto err_del_dev; } @@ -729,6 +733,8 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp) ret = qdev_device_add_from_qdict(qdict, false, errp); if (ret) { + qemu_log("add qdev %s:%s success\n", qemu_opt_get(opts, "driver"), + qemu_opts_id(opts) ? qemu_opts_id(opts) : "none"); qemu_opts_del(opts); } qobject_unref(qdict); diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 10d9b7365aa78430266858fb82abc7165398b2a9..1208815058858a74e6f16e9179f296aa54999c0c 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -707,9 +707,11 @@ static bool main_loop_should_exit(void) } if (qemu_powerdown_requested()) { qemu_system_powerdown(); + qemu_log("domain is power down by outside operation\n"); } if (qemu_vmstop_requested(&r)) { vm_stop(r); + qemu_log("domain is stopped by outside operation\n"); } return false; } diff --git a/softmmu/vl.c b/softmmu/vl.c index d9e4c619d3e1a7929e5c3a8f7e85bb301a15dd26..d8996f3d6eb647575803a59c076b38bdadfda90c 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -26,6 +26,7 @@ #include "qemu-common.h" #include "qemu/datadir.h" #include "qemu/units.h" +#include "qemu/log.h" #include "exec/cpu-common.h" #include "hw/qdev-properties.h" #include "qapi/compat-policy.h" @@ -2680,6 +2681,7 @@ static void qemu_create_cli_devices(void) } /* init generic devices */ + qemu_log("device init start\n"); rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, &error_fatal); @@ -2819,6 +2821,7 @@ void qemu_init(int argc, char **argv, char **envp) qemu_init_subsystems(); + qemu_log("qemu pid is %d, options parsing start\n", getpid()); /* first pass of option parsing */ optind = 1; while (optind < argc) { @@ -3027,6 +3030,7 @@ void qemu_init(int argc, char **argv, char **envp) exit(0); break; case QEMU_OPTION_m: + qemu_log("memory options parse start\n"); opts = qemu_opts_parse_noisily(qemu_find_opts("memory"), optarg, true); if (!opts) { @@ -3744,6 +3748,7 @@ void qemu_init(int argc, char **argv, char **envp) */ machine_class = MACHINE_GET_CLASS(current_machine); + qemu_log("configure accelerator %s start\n", machine_class->name); if (!qtest_enabled() && machine_class->deprecation_reason) { error_report("Machine type '%s' is deprecated: %s", machine_class->name, machine_class->deprecation_reason); @@ -3757,6 +3762,7 @@ void qemu_init(int argc, char **argv, char **envp) qemu_create_late_backends(); + qemu_log("machine init start\n"); /* parse features once if machine provides default cpu_type */ current_machine->cpu_type = machine_class->default_cpu_type; if (cpu_option) {