diff --git a/Makefile b/Makefile index 3f97904a3de8eae9018c76279a54611b21682816..e7c5c3af6fc9160dabe87f14f6d793935ff7bade 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ Makefile: ; configure: ; .PHONY: all clean cscope distclean dvi html info install install-doc \ - pdf recurse-all speed test dist + pdf recurse-all speed test dist msi $(call set-vpath, $(SRC_PATH)) @@ -287,10 +287,32 @@ $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN) qemu-ga$(EXESUF): $(qga-obj-y) libqemuutil.a libqemustub.a $(call LINK, $^) +ifdef QEMU_GA_MSI_ENABLED +QEMU_GA_MSI=qemu-ga-$(ARCH).msi + +msi: ${QEMU_GA_MSI} + +$(QEMU_GA_MSI): qemu-ga.exe + +ifdef QEMU_GA_MSI_WITH_VSS +$(QEMU_GA_MSI): qga/vss-win32/qga-vss.dll +endif + +$(QEMU_GA_MSI): config-host.mak + +$(QEMU_GA_MSI): qga/installer/qemu-ga.wxs + $(call quiet-command,QEMU_GA_VERSION="$(QEMU_GA_VERSION)" QEMU_GA_MANUFACTURER="$(QEMU_GA_MANUFACTURER)" QEMU_GA_DISTRO="$(QEMU_GA_DISTRO)" \ + wixl -o $@ $(QEMU_GA_MSI_ARCH) $(QEMU_GA_MSI_WITH_VSS) $(QEMU_GA_MSI_MINGW_DLL_PATH) $<, " WIXL $@") +else +msi: + @echo MSI build not configured or dependency resolution failed (reconfigure with --enable-guest-agent-msi option) +endif + clean: # avoid old build problems by removing potentially incorrect old files rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h rm -f qemu-options.def + rm -f *.msi find . \( -name '*.l[oa]' -o -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f -exec rm {} + rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~ rm -f fsdev/*.pod diff --git a/configure b/configure index 222694f34d8841f1a55b721408b1aefab06e1810..6fed07b5e2ee95f7c12b456fb8d0357591402186 100755 --- a/configure +++ b/configure @@ -315,6 +315,7 @@ snappy="" bzip2="" guest_agent="" guest_agent_with_vss="no" +guest_agent_msi="" vss_win32_sdk="" win_sdk="no" want_tools="yes" @@ -1078,6 +1079,10 @@ for opt do ;; --disable-guest-agent) guest_agent="no" ;; + --enable-guest-agent-msi) guest_agent_msi="yes" + ;; + --disable-guest-agent-msi) guest_agent_msi="no" + ;; --with-vss-sdk) vss_win32_sdk="" ;; --with-vss-sdk=*) vss_win32_sdk="$optarg" @@ -1394,6 +1399,8 @@ Advanced options (experts only): reading bzip2-compressed dmg images) --disable-guest-agent disable building of the QEMU Guest Agent --enable-guest-agent enable building of the QEMU Guest Agent + --enable-guest-agent-msi enable building guest agent Windows MSI installation package + --disable-guest-agent-msi disable building guest agent Windows MSI installation --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb) --disable-seccomp disable seccomp support @@ -3862,6 +3869,56 @@ if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" fi ########################################## +# Guest agent Window MSI package + +if test "$guest_agent" != yes; then + if test "$guest_agent_msi" = yes; then + error_exit "MSI guest agent package requires guest agent enabled" + fi + guest_agent_msi=no +elif test "$mingw32" != "yes"; then + if test "$guest_agent_msi" = "yes"; then + error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation" + fi + guest_agent_msi=no +elif ! has wixl; then + if test "$guest_agent_msi" = "yes"; then + error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )" + fi + guest_agent_msi=no +fi + +if test "$guest_agent_msi" != "no"; then + if test "$guest_agent_with_vss" = "yes"; then + QEMU_GA_MSI_WITH_VSS="-D InstallVss" + fi + + if test "$QEMU_GA_MANUFACTURER" = ""; then + QEMU_GA_MANUFACTURER=QEMU + fi + + if test "$QEMU_GA_DISTRO" = ""; then + QEMU_GA_DISTRO=Linux + fi + + if test "$QEMU_GA_VERSION" = ""; then + QEMU_GA_VERSION=`cat $source_path/VERSION` + fi + + QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=`$pkg_config --variable=prefix glib-2.0`/bin" + + case "$cpu" in + x86_64) + QEMU_GA_MSI_ARCH="-a x64 -D Arch=64" + ;; + i386) + QEMU_GA_MSI_ARCH="-D Arch=32" + ;; + *) + error_exit "CPU $cpu not supported for building installation package" + ;; + esac +fi ########################################## # check if we have fdatasync @@ -4558,6 +4615,15 @@ if test "$mingw32" = "yes" ; then echo "CONFIG_QGA_VSS=y" >> $config_host_mak echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak fi + if test "$guest_agent_msi" != "no"; then + echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak + echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak + echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak + echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak + echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak + echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak + echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak + fi else echo "CONFIG_POSIX=y" >> $config_host_mak fi diff --git a/exec.c b/exec.c index 76bfc4ac4a8d0e7d55460c785891771762ae793f..f7883d22469b61572b35e6ea7bfad1f22220b4bf 100644 --- a/exec.c +++ b/exec.c @@ -341,6 +341,7 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x hwaddr *plen, bool resolve_subpage) { MemoryRegionSection *section; + MemoryRegion *mr; Int128 diff; section = address_space_lookup_region(d, addr, resolve_subpage); @@ -350,8 +351,11 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x /* Compute offset within MemoryRegion */ *xlat = addr + section->offset_within_region; - diff = int128_sub(section->mr->size, int128_make64(addr)); - *plen = int128_get64(int128_min(diff, int128_make64(*plen))); + mr = section->mr; + if (memory_region_is_ram(mr)) { + diff = int128_sub(section->size, int128_make64(addr)); + *plen = int128_get64(int128_min(diff, int128_make64(*plen))); + } return section; } diff --git a/hw/timer/i8254.c b/hw/timer/i8254.c index 3450c98637da9afeb117b91bb11156ec2a42b070..9b65a336923f99d5277915820accafa976a3e45f 100644 --- a/hw/timer/i8254.c +++ b/hw/timer/i8254.c @@ -196,6 +196,12 @@ static uint64_t pit_ioport_read(void *opaque, hwaddr addr, PITChannelState *s; addr &= 3; + + if (addr == 3) { + /* Mode/Command register is write only, read is ignored */ + return 0; + } + s = &pit->channels[addr]; if (s->status_latched) { s->status_latched = 0; diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c index 32048258c963147717831b1adb233a2ab233fccd..2e3ffc8c073e7f722d9149ea601fb5da0c7e363a 100644 --- a/hw/timer/mc146818rtc.c +++ b/hw/timer/mc146818rtc.c @@ -723,6 +723,12 @@ static int rtc_post_load(void *opaque, int version_id) check_update_timer(s); } + uint64_t now = qemu_clock_get_ns(rtc_clock); + if (now < s->next_periodic_time || + now > (s->next_periodic_time + get_max_clock_jump())) { + periodic_timer_update(s, qemu_clock_get_ns(rtc_clock)); + } + #ifdef TARGET_I386 if (version_id >= 2) { if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) { diff --git a/include/qemu/timer.h b/include/qemu/timer.h index e5bd494c07b7a63458936631eb08593fd4f6d294..9e4f90f4aaeb55390debf8bf829a0cd3bb6d8824 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -787,6 +787,15 @@ static inline int64_t get_ticks_per_sec(void) return 1000000000LL; } +static inline int64_t get_max_clock_jump(void) +{ + /* This should be small enough to prevent excessive interrupts from being + * generated by the RTC on clock jumps, but large enough to avoid frequent + * unnecessary resets in idle VMs. + */ + return 60 * get_ticks_per_sec(); +} + /* * Low level clock functions */ diff --git a/qemu-timer.c b/qemu-timer.c index 5741f0d0e0d95313a537109655f897e93a8a6145..aa6757e35967a0ce6e8dd1d712b533447748ebec 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -573,7 +573,7 @@ int64_t qemu_clock_get_ns(QEMUClockType type) now = get_clock_realtime(); last = clock->last; clock->last = now; - if (now < last) { + if (now < last || now > (last + get_max_clock_jump())) { notifier_list_notify(&clock->reset_notifiers, &now); } return now; diff --git a/qga/channel-win32.c b/qga/channel-win32.c index 0d5e5f511f0271d05774e2539a18e0332f9fa266..04fa5e4d1dfcea99e9fc7b62576bc2ef917582f0 100644 --- a/qga/channel-win32.c +++ b/qga/channel-win32.c @@ -306,7 +306,7 @@ static gboolean ga_channel_open(GAChannel *c, GAChannelMethod method, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED, NULL); if (c->handle == INVALID_HANDLE_VALUE) { - g_critical("error opening path"); + g_critical("error opening path %s", newpath); return false; } diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 3ef0549c0f5c61f8899cf809f962678c59657528..d0aaec70f3c8eff63cec7037629a1a9743e24525 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -721,6 +721,7 @@ GList *ga_command_blacklist_init(GList *blacklist) } if (!vss_init(true)) { + g_debug("vss_init failed, vss commands are going to be disabled"); const char *list[] = { "guest-get-fsinfo", "guest-fsfreeze-status", "guest-fsfreeze-freeze", "guest-fsfreeze-thaw", NULL}; diff --git a/qga/installer/qemu-ga.wxs b/qga/installer/qemu-ga.wxs new file mode 100644 index 0000000000000000000000000000000000000000..2c43f1b5aa2a9c047cfef1e43574b383545fdd69 --- /dev/null +++ b/qga/installer/qemu-ga.wxs @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NOT VersionNT64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NOT Installed + Installed + + + + diff --git a/qga/main.c b/qga/main.c index 9939a2b623b1e27a1f2ac15d97399b5a333524e3..7e1e438f67584924049ba82a3516a1deb5d26c89 100644 --- a/qga/main.c +++ b/qga/main.c @@ -211,7 +211,7 @@ static void usage(const char *cmd) " -V, --version print version information and exit\n" " -d, --daemonize become a daemon\n" #ifdef _WIN32 -" -s, --service service commands: install, uninstall\n" +" -s, --service service commands: install, uninstall, vss-install, vss-uninstall\n" #endif " -b, --blacklist comma-separated list of RPCs to disable (no spaces, \"?\"\n" " to list available RPCs)\n" @@ -1036,6 +1036,14 @@ int main(int argc, char **argv) } else if (strcmp(service, "uninstall") == 0) { ga_uninstall_vss_provider(); return ga_uninstall_service(); + } else if (strcmp(service, "vss-install") == 0) { + if (ga_install_vss_provider()) { + return EXIT_FAILURE; + } + return EXIT_SUCCESS; + } else if (strcmp(service, "vss-uninstall") == 0) { + ga_uninstall_vss_provider(); + return EXIT_SUCCESS; } else { printf("Unknown service command.\n"); return EXIT_FAILURE; diff --git a/tests/Makefile b/tests/Makefile index 4de40deb2f2c04efd574dd7a20b3fea04458bd45..5dd0c56cbb25783851c0fe5590bd24bd75e735e9 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -371,7 +371,7 @@ tests/virtio-balloon-test$(EXESUF): tests/virtio-balloon-test.o tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o $(libqos-virtio-obj-y) tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o $(libqos-pc-obj-y) tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o $(libqos-pc-obj-y) -tests/virtio-scsi-test$(EXESUF): tests/virtio-scsi-test.o +tests/virtio-scsi-test$(EXESUF): tests/virtio-scsi-test.o $(libqos-virtio-obj-y) tests/virtio-9p-test$(EXESUF): tests/virtio-9p-test.o tests/virtio-serial-test$(EXESUF): tests/virtio-serial-test.o tests/virtio-console-test$(EXESUF): tests/virtio-console-test.o diff --git a/tests/libqos/malloc.c b/tests/libqos/malloc.c index 827613005a75970841dbb713759beb3b90b673a5..82b9df537a8293ff9b09b8c31f1d6fd2d4a0b968 100644 --- a/tests/libqos/malloc.c +++ b/tests/libqos/malloc.c @@ -285,6 +285,9 @@ uint64_t guest_alloc(QGuestAllocator *allocator, size_t size) void guest_free(QGuestAllocator *allocator, uint64_t addr) { + if (!addr) { + return; + } mlist_free(allocator, addr); if (allocator->opts & ALLOC_PARANOID) { mlist_check(allocator); diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h index 2449feec592717ef48a50bd2bc71c2bb7cfd32c6..01012787b8384d5302dab96ed0889d5e4b187c5d 100644 --- a/tests/libqos/virtio.h +++ b/tests/libqos/virtio.h @@ -19,8 +19,14 @@ #define QVIRTIO_DRIVER 0x2 #define QVIRTIO_DRIVER_OK 0x4 -#define QVIRTIO_NET_DEVICE_ID 0x1 -#define QVIRTIO_BLK_DEVICE_ID 0x2 +#define QVIRTIO_NET_DEVICE_ID 0x1 +#define QVIRTIO_BLK_DEVICE_ID 0x2 +#define QVIRTIO_CONSOLE_DEVICE_ID 0x3 +#define QVIRTIO_RNG_DEVICE_ID 0x4 +#define QVIRTIO_BALLOON_DEVICE_ID 0x5 +#define QVIRTIO_RPMSG_DEVICE_ID 0x7 +#define QVIRTIO_SCSI_DEVICE_ID 0x8 +#define QVIRTIO_9P_DEVICE_ID 0x9 #define QVIRTIO_F_NOTIFY_ON_EMPTY 0x01000000 #define QVIRTIO_F_ANY_LAYOUT 0x08000000 diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c index 989f8251c4d16454784e6b59fd39e1cdc51c335d..11ccdd632eb9d238fff8dd5994668f8779e1be88 100644 --- a/tests/virtio-scsi-test.c +++ b/tests/virtio-scsi-test.c @@ -2,6 +2,7 @@ * QTest testcase for VirtIO SCSI * * Copyright (c) 2014 SUSE LINUX Products GmbH + * Copyright (c) 2015 Red Hat Inc. * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. @@ -11,16 +12,187 @@ #include #include "libqtest.h" #include "qemu/osdep.h" +#include +#include "libqos/virtio.h" +#include "libqos/virtio-pci.h" +#include "libqos/pci-pc.h" +#include "libqos/malloc.h" +#include "libqos/malloc-pc.h" +#include "libqos/malloc-generic.h" + +#define PCI_SLOT 0x02 +#define PCI_FN 0x00 +#define QVIRTIO_SCSI_TIMEOUT_US (1 * 1000 * 1000) +#define CDB_SIZE 32 + +#define MAX_NUM_QUEUES 64 + +typedef struct { + QVirtioDevice *dev; + QGuestAllocator *alloc; + QPCIBus *bus; + int num_queues; + QVirtQueue *vq[MAX_NUM_QUEUES + 2]; +} QVirtIOSCSI; + +typedef struct { + uint8_t lun[8]; + int64_t tag; + uint8_t task_attr; + uint8_t prio; + uint8_t crn; + uint8_t cdb[CDB_SIZE]; +} QEMU_PACKED QVirtIOSCSICmdReq; + +typedef struct { + uint32_t sense_len; + uint32_t resid; + uint16_t status_qualifier; + uint8_t status; + uint8_t response; + uint8_t sense[96]; +} QEMU_PACKED QVirtIOSCSICmdResp; + +static void qvirtio_scsi_start(const char *extra_opts) +{ + char *cmdline; + + cmdline = g_strdup_printf( + "-drive id=drv0,if=none,file=/dev/null,format=raw " + "-device virtio-scsi-pci,id=vs0 " + "-device scsi-hd,bus=vs0.0,drive=drv0 %s", + extra_opts ? : ""); + qtest_start(cmdline); + g_free(cmdline); +} + +static void qvirtio_scsi_stop(void) +{ + qtest_end(); +} + +static QVirtIOSCSI *qvirtio_scsi_pci_init(int slot) +{ + QVirtIOSCSI *vs; + QVirtioPCIDevice *dev; + void *addr; + int i; + + vs = g_new0(QVirtIOSCSI, 1); + vs->alloc = pc_alloc_init(); + vs->bus = qpci_init_pc(); + + dev = qvirtio_pci_device_find(vs->bus, QVIRTIO_SCSI_DEVICE_ID); + vs->dev = (QVirtioDevice *)dev; + g_assert(dev != NULL); + g_assert_cmphex(vs->dev->device_type, ==, QVIRTIO_SCSI_DEVICE_ID); + + qvirtio_pci_device_enable(dev); + qvirtio_reset(&qvirtio_pci, vs->dev); + qvirtio_set_acknowledge(&qvirtio_pci, vs->dev); + qvirtio_set_driver(&qvirtio_pci, vs->dev); + + addr = dev->addr + QVIRTIO_PCI_DEVICE_SPECIFIC_NO_MSIX; + vs->num_queues = qvirtio_config_readl(&qvirtio_pci, vs->dev, + (uint64_t)(uintptr_t)addr); + + g_assert_cmpint(vs->num_queues, <, MAX_NUM_QUEUES); + + for (i = 0; i < vs->num_queues + 2; i++) { + vs->vq[i] = qvirtqueue_setup(&qvirtio_pci, vs->dev, vs->alloc, i); + } + + return vs; +} + +static void qvirtio_scsi_pci_free(QVirtIOSCSI *vs) +{ + int i; + + for (i = 0; i < vs->num_queues + 2; i++) { + guest_free(vs->alloc, vs->vq[i]->desc); + } + pc_alloc_uninit(vs->alloc); + qvirtio_pci_device_disable(container_of(vs->dev, QVirtioPCIDevice, vdev)); + g_free(vs->dev); + qpci_free_pc(vs->bus); +} + +static uint64_t qvirtio_scsi_alloc(QVirtIOSCSI *vs, size_t alloc_size, + const void *data) +{ + uint64_t addr; + + addr = guest_alloc(vs->alloc, alloc_size); + if (data) { + memwrite(addr, data, alloc_size); + } + + return addr; +} + +static uint8_t virtio_scsi_do_command(QVirtIOSCSI *vs, const uint8_t *cdb, + const uint8_t *data_in, + size_t data_in_len, + uint8_t *data_out, size_t data_out_len) +{ + QVirtQueue *vq; + QVirtIOSCSICmdReq req = { { 0 } }; + QVirtIOSCSICmdResp resp = { .response = 0xff, .status = 0xff }; + uint64_t req_addr, resp_addr, data_in_addr = 0, data_out_addr = 0; + uint8_t response; + uint32_t free_head; + + vq = vs->vq[2]; + + req.lun[0] = 1; /* Select LUN */ + req.lun[1] = 1; /* Select target 1 */ + memcpy(req.cdb, cdb, CDB_SIZE); + + /* XXX: Fix endian if any multi-byte field in req/resp is used */ + + /* Add request header */ + req_addr = qvirtio_scsi_alloc(vs, sizeof(req), &req); + free_head = qvirtqueue_add(vq, req_addr, sizeof(req), false, true); + + if (data_out_len) { + data_out_addr = qvirtio_scsi_alloc(vs, data_out_len, data_out); + qvirtqueue_add(vq, data_out_addr, data_out_len, false, true); + } + + /* Add response header */ + resp_addr = qvirtio_scsi_alloc(vs, sizeof(resp), &resp); + qvirtqueue_add(vq, resp_addr, sizeof(resp), true, !!data_in_len); + + if (data_in_len) { + data_in_addr = qvirtio_scsi_alloc(vs, data_in_len, data_in); + qvirtqueue_add(vq, data_in_addr, data_in_len, true, false); + } + + qvirtqueue_kick(&qvirtio_pci, vs->dev, vq, free_head); + qvirtio_wait_queue_isr(&qvirtio_pci, vs->dev, vq, QVIRTIO_SCSI_TIMEOUT_US); + + response = readb(resp_addr + offsetof(QVirtIOSCSICmdResp, response)); + + guest_free(vs->alloc, req_addr); + guest_free(vs->alloc, resp_addr); + guest_free(vs->alloc, data_in_addr); + guest_free(vs->alloc, data_out_addr); + return response; +} /* Tests only initialization so far. TODO: Replace with functional tests */ static void pci_nop(void) { + qvirtio_scsi_start(NULL); + qvirtio_scsi_stop(); } static void hotplug(void) { QDict *response; + qvirtio_scsi_start("-drive id=drv1,if=none,file=/dev/null,format=raw"); response = qmp("{\"execute\": \"device_add\"," " \"arguments\": {" " \"driver\": \"scsi-hd\"," @@ -42,6 +214,27 @@ static void hotplug(void) g_assert(qdict_haskey(response, "event")); g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); QDECREF(response); + qvirtio_scsi_stop(); +} + +/* Test WRITE SAME with the lba not aligned */ +static void test_unaligned_write_same(void) +{ + QVirtIOSCSI *vs; + uint8_t buf[512] = { 0 }; + const uint8_t write_same_cdb[CDB_SIZE] = { 0x41, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x02, 0x00 }; + + qvirtio_scsi_start("-drive file=blkdebug::null-co://,if=none,id=dr1" + ",format=raw,file.align=4k " + "-device scsi-disk,drive=dr1,lun=0,scsi-id=1"); + vs = qvirtio_scsi_pci_init(PCI_SLOT); + + g_assert_cmphex(0, ==, + virtio_scsi_do_command(vs, write_same_cdb, NULL, 0, buf, 512)); + + qvirtio_scsi_pci_free(vs); + qvirtio_scsi_stop(); } int main(int argc, char **argv) @@ -51,14 +244,10 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); qtest_add_func("/virtio/scsi/pci/nop", pci_nop); qtest_add_func("/virtio/scsi/pci/hotplug", hotplug); + qtest_add_func("/virtio/scsi/pci/scsi-disk/unaligned-write-same", + test_unaligned_write_same); - qtest_start("-drive id=drv0,if=none,file=/dev/null,format=raw " - "-drive id=drv1,if=none,file=/dev/null,format=raw " - "-device virtio-scsi-pci,id=vscsi0 " - "-device scsi-hd,bus=vscsi0.0,drive=drv0"); ret = g_test_run(); - qtest_end(); - return ret; } diff --git a/vl.c b/vl.c index 278cd6af61b88172ad95116e3e6d2b17af5ba6c5..1a920e6bcc09ee036b8ca6ccbf03480d5c278454 100644 --- a/vl.c +++ b/vl.c @@ -3997,17 +3997,14 @@ int main(int argc, char **argv, char **envp) exit(0); } - /* Open the logfile at this point, if necessary. We can't open the logfile - * when encountering either of the logging options (-d or -D) because the - * other one may be encountered later on the command line, changing the - * location or level of logging. + /* Open the logfile at this point and set the log mask if necessary. */ + if (log_file) { + qemu_set_log_filename(log_file); + } + if (log_mask) { int mask; - if (log_file) { - qemu_set_log_filename(log_file); - } - mask = qemu_str_to_log_mask(log_mask); if (!mask) { qemu_print_log_usage(stdout);