[Qemu-devel] [PATCH v2] use g_free, instead of free
From: Dong Xu Wang wdon...@linux.vnet.ibm.com Fix mismatching allocation and deallocation: g_free should be used to pair with g_malloc. Also fix coding style. Signed-off-by: Dong Xu Wang wdon...@linux.vnet.ibm.com --- block/cloop.c | 119 +++-- 1 files changed, 65 insertions(+), 54 deletions(-) diff --git a/block/cloop.c b/block/cloop.c index 775f8a9..1884b8c 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -30,7 +30,7 @@ typedef struct BDRVCloopState { CoMutex lock; uint32_t block_size; uint32_t n_blocks; -uint64_t* offsets; +uint64_t *offsets; uint32_t sectors_per_block; uint32_t current_block; uint8_t *compressed_block; @@ -40,21 +40,23 @@ typedef struct BDRVCloopState { static int cloop_probe(const uint8_t *buf, int buf_size, const char *filename) { -const char* magic_version_2_0=#!/bin/sh\n - #V2.0 Format\n - modprobe cloop file=$0 mount -r -t iso9660 /dev/cloop $1\n; -int length=strlen(magic_version_2_0); -if(lengthbuf_size) - length=buf_size; -if(!memcmp(magic_version_2_0,buf,length)) - return 2; +const char *magic_version_2_0 = #!/bin/sh\n +#V2.0 Format\n +modprobe cloop file=$0 mount -r -t iso9660 /dev/cloop $1\n; +int length = strlen(magic_version_2_0); +if (length buf_size) { +length = buf_size; +} +if (!memcmp(magic_version_2_0, buf, length)) { +return 2; +} return 0; } static int cloop_open(BlockDriverState *bs, int flags) { BDRVCloopState *s = bs-opaque; -uint32_t offsets_size,max_compressed_block_size=1,i; +uint32_t offsets_size, max_compressed_block_size = 1, i; bs-read_only = 1; @@ -74,26 +76,28 @@ static int cloop_open(BlockDriverState *bs, int flags) s-offsets = g_malloc(offsets_size); if (bdrv_pread(bs-file, 128 + 4 + 4, s-offsets, offsets_size) offsets_size) { - goto cloop_close; +goto cloop_close; } for(i=0;is-n_blocks;i++) { - s-offsets[i]=be64_to_cpu(s-offsets[i]); - if(i0) { - uint32_t size=s-offsets[i]-s-offsets[i-1]; - if(sizemax_compressed_block_size) - max_compressed_block_size=size; - } +s-offsets[i] = be64_to_cpu(s-offsets[i]); +if (i 0) { +uint32_t size = s-offsets[i] - s-offsets[i-1]; +if (size max_compressed_block_size) { +max_compressed_block_size = size; +} +} } /* initialize zlib engine */ -s-compressed_block = g_malloc(max_compressed_block_size+1); +s-compressed_block = g_malloc(max_compressed_block_size + 1); s-uncompressed_block = g_malloc(s-block_size); -if(inflateInit(s-zstream) != Z_OK) - goto cloop_close; -s-current_block=s-n_blocks; +if (inflateInit(s-zstream) != Z_OK) { +goto cloop_close; +} +s-current_block = s-n_blocks; s-sectors_per_block = s-block_size/512; -bs-total_sectors = s-n_blocks*s-sectors_per_block; +bs-total_sectors = s-n_blocks * s-sectors_per_block; qemu_co_mutex_init(s-lock); return 0; @@ -105,27 +109,30 @@ static inline int cloop_read_block(BlockDriverState *bs, int block_num) { BDRVCloopState *s = bs-opaque; -if(s-current_block != block_num) { - int ret; -uint32_t bytes = s-offsets[block_num+1]-s-offsets[block_num]; +if (s-current_block != block_num) { +int ret; +uint32_t bytes = s-offsets[block_num + 1]-s-offsets[block_num]; ret = bdrv_pread(bs-file, s-offsets[block_num], s-compressed_block, bytes); -if (ret != bytes) +if (ret != bytes) { return -1; +} + +s-zstream.next_in = s-compressed_block; +s-zstream.avail_in = bytes; +s-zstream.next_out = s-uncompressed_block; +s-zstream.avail_out = s-block_size; +ret = inflateReset(s-zstream); +if (ret != Z_OK) { +return -1; +} +ret = inflate(s-zstream, Z_FINISH); +if (ret != Z_STREAM_END || s-zstream.total_out != s-block_size) { +return -1; +} - s-zstream.next_in = s-compressed_block; - s-zstream.avail_in = bytes; - s-zstream.next_out = s-uncompressed_block; - s-zstream.avail_out = s-block_size; - ret = inflateReset(s-zstream); - if(ret != Z_OK) - return -1; - ret = inflate(s-zstream, Z_FINISH); - if(ret != Z_STREAM_END || s-zstream.total_out != s-block_size) - return -1; - - s-current_block = block_num; +s-current_block = block_num; } return 0; } @@ -136,12 +143,15 @@ static int cloop_read(BlockDriverState *bs, int64_t sector_num, BDRVCloopState *s = bs-opaque; int i; -for(i=0;inb_sectors;i++) { - uint32_t sector_offset_in_block=((sector_num+i)%s-sectors_per_block), -
[Qemu-devel] [PULL 0/4] Trivial patches for 27 October to 1 November 2011
The following changes since commit ff74c5a9a91c6dbf1017195462aa4176f7381240: Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging (2011-10-31 15:05:40 -0500) are available in the git repository at: ssh://repo.or.cz/srv/git/qemu/stefanha.git trivial-patches Luiz Capitulino (1): net: tap-linux: Fix unhelpful error message Markus Armbruster (2): sysbus: Supply missing va_end() acl: Fix use after free in qemu_acl_reset() Stefan Hajnoczi (1): qapi: fix typos in documentation JSON examples acl.c |4 ++-- docs/qapi-code-gen.txt |4 ++-- hw/sysbus.c|2 ++ net/tap-linux.c|6 +- 4 files changed, 11 insertions(+), 5 deletions(-) -- 1.7.7
[Qemu-devel] [PATCH 2/4] sysbus: Supply missing va_end()
From: Markus Armbruster arm...@redhat.com C99 7.15.1: Each invocation of the va_start and va_copy macros shall be matched by a corresponding invocation of the va_end macro in the same function. Spotted by Coverity. Harmless on the (common) systems where va_end() does nothing. Signed-off-by: Markus Armbruster arm...@redhat.com Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com --- hw/sysbus.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/hw/sysbus.c b/hw/sysbus.c index 4fab5a4..fd2fc6a 100644 --- a/hw/sysbus.c +++ b/hw/sysbus.c @@ -198,6 +198,7 @@ DeviceState *sysbus_create_varargs(const char *name, sysbus_connect_irq(s, n, irq); n++; } +va_end(va); return dev; } @@ -229,6 +230,7 @@ DeviceState *sysbus_try_create_varargs(const char *name, sysbus_connect_irq(s, n, irq); n++; } +va_end(va); return dev; } -- 1.7.7
[Qemu-devel] [PATCH 3/4] qapi: fix typos in documentation JSON examples
Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com --- docs/qapi-code-gen.txt |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt index f345866..c0a9325 100644 --- a/docs/qapi-code-gen.txt +++ b/docs/qapi-code-gen.txt @@ -41,7 +41,7 @@ dictionary. This corresponds to a struct in C or an Object in JSON. An example of a complex type is: { 'type': 'MyType', - 'data' { 'member1': 'str', 'member2': 'int', '*member3': 'str } } + 'data': { 'member1': 'str', 'member2': 'int', '*member3': 'str' } } The use of '*' as a prefix to the name means the member is optional. Optional members should always be added to the end of the dictionary to preserve @@ -63,7 +63,7 @@ An example command is: { 'command': 'my-command', 'data': { 'arg1': 'str', '*arg2': 'str' }, - 'returns': 'str' ] + 'returns': 'str' } Command names should be all lower case with words separated by a hyphen. -- 1.7.7
[Qemu-devel] [PATCH 4/4] acl: Fix use after free in qemu_acl_reset()
From: Markus Armbruster arm...@redhat.com Reproducer: $ MALLOC_PERTURB_=234 qemu-system-x86_64 -vnc :0,acl,sasl [...] QEMU 0.15.50 monitor - type 'help' for more information (qemu) acl_add vnc.username fred allow acl: added rule at position 1 (qemu) acl_reset vnc.username Segmentation fault (core dumped) Spotted by Coverity. Signed-off-by: Markus Armbruster arm...@redhat.com Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com --- acl.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/acl.c b/acl.c index 0654f38..e840b9b 100644 --- a/acl.c +++ b/acl.c @@ -95,13 +95,13 @@ int qemu_acl_party_is_allowed(qemu_acl *acl, void qemu_acl_reset(qemu_acl *acl) { -qemu_acl_entry *entry; +qemu_acl_entry *entry, *next_entry; /* Put back to deny by default, so there is no window * of open access while the user re-initializes the * access control list */ acl-defaultDeny = 1; -QTAILQ_FOREACH(entry, acl-entries, next) { +QTAILQ_FOREACH_SAFE(entry, acl-entries, next, next_entry) { QTAILQ_REMOVE(acl-entries, entry, next); free(entry-match); free(entry); -- 1.7.7
[Qemu-devel] [PATCH 1/4] net: tap-linux: Fix unhelpful error message
From: Luiz Capitulino lcapitul...@redhat.com I'm getting: could not configure /dev/net/tun (tap%d): Operation not permitted When the ioctl() fails, ifr.ifr_name will most likely not be overwritten. So we better only use it when ifname contains a string. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com --- net/tap-linux.c |6 +- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/net/tap-linux.c b/net/tap-linux.c index ff8cad0..41d581b 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -73,7 +73,11 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required pstrcpy(ifr.ifr_name, IFNAMSIZ, tap%d); ret = ioctl(fd, TUNSETIFF, (void *) ifr); if (ret != 0) { -error_report(could not configure %s (%s): %m, PATH_NET_TUN, ifr.ifr_name); +if (ifname[0] != '\0') { +error_report(could not configure %s (%s): %m, PATH_NET_TUN, ifr.ifr_name); +} else { +error_report(could not configure %s: %m, PATH_NET_TUN); +} close(fd); return -1; } -- 1.7.7
Re: [Qemu-devel] [patch] explicitly initialize tcg_cpu_thread
On Tue, Nov 1, 2011 at 7:35 AM, Jun Koi junkoi2...@gmail.com wrote: This patch explicitly initializes tcg_cpu_thread to NULL in cpus.c (One code patch in qemu_tcg_init_vcpu() relies on the value of tcg_cpu_thread to create env-thread and so on ) Signed-off-by: Jun Koi junkoi2...@gmail.com You don't need to explicitly initialize objects with static storage duration. They are initialized to NULL/0 implicitly. This is guaranteed by the C standard. -- Pavel diff --git a/cpus.c b/cpus.c index f768683..47feb58 100644 --- a/cpus.c +++ b/cpus.c @@ -606,7 +606,7 @@ static bool iothread_requesting_mutex; static QemuThread io_thread; -static QemuThread *tcg_cpu_thread; +static QemuThread *tcg_cpu_thread = NULL; static QemuCond *tcg_halt_cond; /* cpu creation */
Re: [Qemu-devel] [PATCH] block.c typo in comment fixed
Am 01.11.2011 02:36, schrieb matthias@googlemail.com: From: Matthias Bruggermatthias@gmail.com Signed-off-by: Matthias Bruggermatthias@gmail.com --- block.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/block.c b/block.c index 9bb236c..480aae2 100644 --- a/block.c +++ b/block.c @@ -497,7 +497,7 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename, open_flags = flags ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); /* - * Snapshots should be writable. + * Snapshots should be writeable. */ if (bs-is_temporary) { open_flags |= BDRV_O_RDWR; Hi Matthias, both writable and writeable seem to be correct, but http://oxforddictionaries.com/ says that writable is the only correct spelling. Therefore your patch should not be used. Cheers, Stefan
Re: [Qemu-devel] buildbot failure in qemu on xen_x86_64_debian_6_0
Am 01.11.2011 07:19, schrieb q...@buildbot.b1-systems.de: The Buildbot has detected a new failure on builder xen_x86_64_debian_6_0 while building qemu. Full details are available at: http://buildbot.b1-systems.de/qemu/builders/xen_x86_64_debian_6_0/builds/78 Buildbot URL: http://buildbot.b1-systems.de/qemu/ Buildslave for this Build: yuzuki Build Reason: The Nightly scheduler named 'nightly_xen' triggered this build Build Source Stamp: [branch xen-next] HEAD Blamelist: BUILD FAILED: failed git sincerely, -The Buildbot As far as I know from previous mails, the buildbots already do a retry when git fails. The retry period used today is obviously too short. We know that git fails rather often and that those failures take some time. Is there any reason why a buildbot cannot retry until it succeeds with a much larger time limit than today? A git retry limit of several hours or even a day would not harm. Mails from the buildbot are only useful if some user action is required - when git fails, you can only wait. Developers who want a fast feedback for their latest commits can either poll the buildbot, or the buildbot must be configured to send individual mails with more information. Regards, Stefan Weil
[Qemu-devel] [PATCH v10 0/3] The intro of QEMU block I/O throttling
The main goal of the patch is to effectively cap the disk I/O speed or counts of one single VM.It is only one draft, so it unavoidably has some drawbacks, if you catch them, please let me know. The patch will mainly introduce one block I/O throttling algorithm, one timer and one block queue for each I/O limits enabled drive. When a block request is coming in, the throttling algorithm will check if its I/O rate or counts exceed the limits; if yes, then it will enqueue to the block queue; The timer will handle the I/O requests in it. Some available features follow as below: (1) global bps limit. -drive bps=xxxin bytes/s (2) only read bps limit -drive bps_rd=xxx in bytes/s (3) only write bps limit -drive bps_wr=xxx in bytes/s (4) global iops limit -drive iops=xxx in ios/s (5) only read iops limit -drive iops_rd=xxxin ios/s (6) only write iops limit -drive iops_wr=xxxin ios/s (7) the combination of some limits. -drive bps=xxx,iops=xxx Known Limitations: (1) #1 can not coexist with #2, #3 (2) #4 can not coexist with #5, #6 Changes since code V9: Greately simply the logic and rebase request queue to CoQueue based on Stefan's comments. v9: made a lot of changes based on kevin's comments. slice_time is dynamically adjusted based on wait_time. rebase the latest qemu upstream. v8: fix the build per patch based on stefan's comments. v7: Mainly simply the block queue. Adjust codes based on stefan's comments. v6: Mainly fix the aio callback issue for block queue. Adjust codes based on Ram Pai's comments. v5: add qmp/hmp support. Adjust the codes based on stefan's comments qmp/hmp: add block_set_io_throttle v4: fix memory leaking based on ryan's feedback. v3: Added the code for extending slice time, and modified the method to compute wait time for the timer. v2: The codes V2 for QEMU disk I/O limits. Modified the codes mainly based on stefan's comments. v1: Submit the codes for QEMU disk I/O limits. Only a code draft. Zhi Yong Wu (3): block: add the command line support block: add I/O throttling algorithm hmp/qmp: add block_set_io_throttle block.c | 283 + block.h |5 + block_int.h | 30 + blockdev.c| 83 ++ blockdev.h|2 + hmp-commands.hx | 15 +++ hmp.c | 10 ++ qapi-schema.json | 16 +++- qemu-config.c | 24 qemu-coroutine-lock.c |8 ++ qemu-coroutine.h |6 + qemu-options.hx |1 + qerror.c |4 + qerror.h |3 + qmp-commands.hx | 53 +- 15 files changed, 541 insertions(+), 2 deletions(-) -- 1.7.6
[Qemu-devel] [PATCH V2] Introduce a new bus ICC to connect APIC
From: Liu Ping Fan pingf...@linux.vnet.ibm.com Introduce a new structure CPUS as the controller of ICC (INTERRUPT CONTROLLER COMMUNICATIONS), and new bus ICC to hold APIC,instead of sysbus. So we can support APIC hot-plug feature. Signed-off-by: liu ping fan pingf...@linux.vnet.ibm.com --- Makefile.target |1 + hw/apic.c | 24 + hw/apic.h |1 + hw/icc_bus.c| 92 +++ hw/icc_bus.h| 61 + hw/pc.c |9 +++-- hw/pc_piix.c| 14 +++- target-i386/cpu.h |1 + target-i386/cpuid.c | 16 + 9 files changed, 207 insertions(+), 12 deletions(-) create mode 100644 hw/icc_bus.c create mode 100644 hw/icc_bus.h diff --git a/Makefile.target b/Makefile.target index 9011f28..5607c6d 100644 --- a/Makefile.target +++ b/Makefile.target @@ -241,6 +241,7 @@ obj-i386-$(CONFIG_KVM) += kvmclock.o obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o obj-i386-y += testdev.o obj-i386-y += acpi.o acpi_piix4.o +obj-i386-y += icc_bus.o obj-i386-y += pcspk.o i8254.o obj-i386-$(CONFIG_KVM_PIT) += i8254-kvm.o diff --git a/hw/apic.c b/hw/apic.c index 69d6ac5..34fa1dd 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -21,9 +21,10 @@ #include ioapic.h #include qemu-timer.h #include host-utils.h -#include sysbus.h +#include icc_bus.h #include trace.h #include kvm.h +#include exec-memory.h /* APIC Local Vector Table */ #define APIC_LVT_TIMER 0 @@ -80,7 +81,7 @@ typedef struct APICState APICState; struct APICState { -SysBusDevice busdev; +ICCBusDevice busdev; MemoryRegion io_memory; void *cpu_env; uint32_t apicbase; @@ -1104,9 +1105,19 @@ static const MemoryRegionOps apic_io_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -static int apic_init1(SysBusDevice *dev) +int apic_mmio_map(DeviceState *dev, target_phys_addr_t base) { -APICState *s = FROM_SYSBUS(APICState, dev); +APICState *s = DO_UPCAST(APICState, busdev.qdev, dev); + +memory_region_add_subregion(get_system_memory(), +base, +s-io_memory); +return 0; +} + +static int apic_init1(ICCBusDevice *dev) +{ +APICState *s = DO_UPCAST(APICState, busdev, dev); static int last_apic_idx; if (last_apic_idx = MAX_APICS) { @@ -1114,7 +1125,6 @@ static int apic_init1(SysBusDevice *dev) } memory_region_init_io(s-io_memory, apic_io_ops, s, apic, MSI_ADDR_SIZE); -sysbus_init_mmio_region(dev, s-io_memory); s-timer = qemu_new_timer_ns(vm_clock, apic_timer, s); s-idx = last_apic_idx++; @@ -1122,7 +1132,7 @@ static int apic_init1(SysBusDevice *dev) return 0; } -static SysBusDeviceInfo apic_info = { +static ICCBusDeviceInfo apic_info = { .init = apic_init1, .qdev.name = apic, .qdev.size = sizeof(APICState), @@ -1138,7 +1148,7 @@ static SysBusDeviceInfo apic_info = { static void apic_register_devices(void) { -sysbus_register_withprop(apic_info); +iccbus_register_devinfo(apic_info); } device_init(apic_register_devices) diff --git a/hw/apic.h b/hw/apic.h index c857d52..e2c0af5 100644 --- a/hw/apic.h +++ b/hw/apic.h @@ -20,6 +20,7 @@ void cpu_set_apic_tpr(DeviceState *s, uint8_t val); uint8_t cpu_get_apic_tpr(DeviceState *s); void apic_init_reset(DeviceState *s); void apic_sipi(DeviceState *s); +int apic_mmio_map(DeviceState *dev, target_phys_addr_t base); /* pc.c */ int cpu_is_bsp(CPUState *env); diff --git a/hw/icc_bus.c b/hw/icc_bus.c new file mode 100644 index 000..ac88f2e --- /dev/null +++ b/hw/icc_bus.c @@ -0,0 +1,92 @@ +/* icc_bus.c + * emulate x86 ICC(INTERRUPT CONTROLLER COMMUNICATIONS) bus + * + * Copyright IBM, Corp. 2011 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see http://www.gnu.org/licenses/ + */ +#include icc_bus.h + +static CPUSockets *cpu_sockets; + +static ICCBusInfo icc_bus_info = { +.qinfo.name = icc, +.qinfo.size = sizeof(ICCBus), +.qinfo.props = (Property[]) { +DEFINE_PROP_END_OF_LIST(), +} +}; + +static int iccbus_device_init(DeviceState *dev, DeviceInfo *base) +{ +ICCBusDeviceInfo *info = container_of(base, ICCBusDeviceInfo, qdev); +ICCBusDevice *idev = DO_UPCAST(ICCBusDevice, qdev, dev); + +return info-init(idev); +} + +void
[Qemu-devel] [PATCH v10 1/3] block: add the command line support
Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com --- block.c | 40 block.h |4 block_int.h | 29 + blockdev.c | 32 qemu-config.c | 24 qemu-options.hx |1 + 6 files changed, 130 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 9bb236c..8f08dc5 100644 --- a/block.c +++ b/block.c @@ -30,6 +30,7 @@ #include qjson.h #include qemu-coroutine.h #include qmp-commands.h +#include qemu-timer.h #ifdef CONFIG_BSD #include sys/types.h @@ -105,6 +106,37 @@ int is_windows_drive(const char *filename) } #endif +/* throttling disk I/O limits */ +static void bdrv_block_timer(void *opaque) +{ +BlockDriverState *bs = opaque; + +qemu_co_queue_next(bs-throttled_reqs); +} + +void bdrv_io_limits_enable(BlockDriverState *bs) +{ +bs-io_limits_enabled = true; +qemu_co_queue_init(bs-throttled_reqs); + +bs-block_timer = qemu_new_timer_ns(vm_clock, bdrv_block_timer, bs); +bs-slice_time= 5 * BLOCK_IO_SLICE_TIME; +bs-slice_start = qemu_get_clock_ns(vm_clock); +bs-slice_end = bs-slice_start + bs-slice_time; +memset(bs-io_disps, 0, sizeof(bs-io_disps)); +} + +bool bdrv_io_limits_enabled(BlockDriverState *bs) +{ +BlockIOLimit *io_limits = bs-io_limits; +return io_limits-bps[BLOCK_IO_LIMIT_READ] + || io_limits-bps[BLOCK_IO_LIMIT_WRITE] + || io_limits-bps[BLOCK_IO_LIMIT_TOTAL] + || io_limits-iops[BLOCK_IO_LIMIT_READ] + || io_limits-iops[BLOCK_IO_LIMIT_WRITE] + || io_limits-iops[BLOCK_IO_LIMIT_TOTAL]; +} + /* check if the path starts with protocol: */ static int path_has_protocol(const char *path) { @@ -1519,6 +1551,14 @@ void bdrv_get_geometry_hint(BlockDriverState *bs, *psecs = bs-secs; } +/* throttling disk io limits */ +void bdrv_set_io_limits(BlockDriverState *bs, +BlockIOLimit *io_limits) +{ +bs-io_limits = *io_limits; +bs-io_limits_enabled = bdrv_io_limits_enabled(bs); +} + /* Recognize floppy formats */ typedef struct FDFormat { FDriveType drive; diff --git a/block.h b/block.h index 38cd748..bc8315d 100644 --- a/block.h +++ b/block.h @@ -89,6 +89,10 @@ void bdrv_info(Monitor *mon, QObject **ret_data); void bdrv_stats_print(Monitor *mon, const QObject *data); void bdrv_info_stats(Monitor *mon, QObject **ret_data); +/* disk I/O throttling */ +void bdrv_io_limits_enable(BlockDriverState *bs); +bool bdrv_io_limits_enabled(BlockDriverState *bs); + void bdrv_init(void); void bdrv_init_with_whitelist(void); BlockDriver *bdrv_find_protocol(const char *filename); diff --git a/block_int.h b/block_int.h index f4547f6..b835ef6 100644 --- a/block_int.h +++ b/block_int.h @@ -34,6 +34,12 @@ #define BLOCK_FLAG_ENCRYPT 1 #define BLOCK_FLAG_COMPAT6 4 +#define BLOCK_IO_LIMIT_READ 0 +#define BLOCK_IO_LIMIT_WRITE1 +#define BLOCK_IO_LIMIT_TOTAL2 + +#define BLOCK_IO_SLICE_TIME 1 + #define BLOCK_OPT_SIZE size #define BLOCK_OPT_ENCRYPT encryption #define BLOCK_OPT_COMPAT6 compat6 @@ -50,6 +56,16 @@ typedef struct AIOPool { BlockDriverAIOCB *free_aiocb; } AIOPool; +typedef struct BlockIOLimit { +uint64_t bps[3]; +uint64_t iops[3]; +} BlockIOLimit; + +typedef struct BlockIODisp { +uint64_t bytes[2]; +uint64_t ios[2]; +} BlockIODisp; + struct BlockDriver { const char *format_name; int instance_size; @@ -184,6 +200,16 @@ struct BlockDriverState { void *sync_aiocb; +/* the time for latest disk I/O */ +int64_t slice_time; +int64_t slice_start; +int64_t slice_end; +BlockIOLimit io_limits; +BlockIODisp io_disps; +CoQueue throttled_reqs; +QEMUTimer*block_timer; +bool io_limits_enabled; + /* I/O stats (display with info blockstats). */ uint64_t nr_bytes[BDRV_MAX_IOTYPE]; uint64_t nr_ops[BDRV_MAX_IOTYPE]; @@ -227,6 +253,9 @@ void *qemu_aio_get(AIOPool *pool, BlockDriverState *bs, BlockDriverCompletionFunc *cb, void *opaque); void qemu_aio_release(void *p); +void bdrv_set_io_limits(BlockDriverState *bs, +BlockIOLimit *io_limits); + #ifdef _WIN32 int is_windows_drive(const char *filename); #endif diff --git a/blockdev.c b/blockdev.c index 0827bf7..faf8c56 100644 --- a/blockdev.c +++ b/blockdev.c @@ -235,6 +235,9 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) int on_read_error, on_write_error; const char *devaddr; DriveInfo *dinfo; +BlockIOLimit io_limits; +bool bps_iol; +bool iops_iol; int snapshot = 0; int ret; @@ -353,6 +356,32 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) } } +/* disk I/O throttling */ +io_limits.bps[BLOCK_IO_LIMIT_TOTAL] = + qemu_opt_get_number(opts, bps,
[Qemu-devel] [PATCH v10 2/3] block: add I/O throttling algorithm
Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com --- block.c | 228 + block.h |1 + block_int.h |1 + qemu-coroutine-lock.c |8 ++ qemu-coroutine.h |6 ++ 5 files changed, 244 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 8f08dc5..cb89372 100644 --- a/block.c +++ b/block.c @@ -74,6 +74,13 @@ static BlockDriverAIOCB *bdrv_co_aio_rw_vector(BlockDriverState *bs, bool is_write); static void coroutine_fn bdrv_co_do_rw(void *opaque); +static bool bdrv_exceed_bps_limits(BlockDriverState *bs, int nb_sectors, +bool is_write, double elapsed_time, uint64_t *wait); +static bool bdrv_exceed_iops_limits(BlockDriverState *bs, bool is_write, +double elapsed_time, uint64_t *wait); +static bool bdrv_exceed_io_limits(BlockDriverState *bs, int nb_sectors, +bool is_write, int64_t *wait); + static QTAILQ_HEAD(, BlockDriverState) bdrv_states = QTAILQ_HEAD_INITIALIZER(bdrv_states); @@ -107,6 +114,28 @@ int is_windows_drive(const char *filename) #endif /* throttling disk I/O limits */ +void bdrv_io_limits_disable(BlockDriverState *bs) +{ +bs-io_limits_enabled = false; + +if (!qemu_co_queue_empty(bs-throttled_reqs)) { +while (qemu_co_queue_next(bs-throttled_reqs)); +} + +qemu_co_queue_init(bs-throttled_reqs); + +if (bs-block_timer) { +qemu_del_timer(bs-block_timer); +qemu_free_timer(bs-block_timer); +bs-block_timer = NULL; +} + +bs-slice_start = 0; +bs-slice_end = 0; +bs-slice_time = 0; +memset(bs-io_disps, 0, sizeof(bs-io_disps)); +} + static void bdrv_block_timer(void *opaque) { BlockDriverState *bs = opaque; @@ -137,6 +166,33 @@ bool bdrv_io_limits_enabled(BlockDriverState *bs) || io_limits-iops[BLOCK_IO_LIMIT_TOTAL]; } +static void bdrv_io_limits_intercept(BlockDriverState *bs, + int nb_sectors) +{ +int64_t wait_time = -1; + +if (!qemu_co_queue_empty(bs-throttled_reqs)) { +qemu_co_queue_wait(bs-throttled_reqs); +goto resume; +} else if (bdrv_exceed_io_limits(bs, nb_sectors, false, wait_time)) { +if (wait_time != -1) { +qemu_mod_timer(bs-block_timer, + wait_time + qemu_get_clock_ns(vm_clock)); +} + +qemu_co_queue_wait(bs-throttled_reqs); + +resume: +while (bdrv_exceed_io_limits(bs, nb_sectors, false, wait_time)) { +qemu_mod_timer(bs-block_timer, + wait_time + qemu_get_clock_ns(vm_clock)); +qemu_co_queue_wait_insert_head(bs-throttled_reqs); +} + +qemu_co_queue_next(bs-throttled_reqs); +} +} + /* check if the path starts with protocol: */ static int path_has_protocol(const char *path) { @@ -719,6 +775,11 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags, bdrv_dev_change_media_cb(bs, true); } +/* throttling disk I/O limits */ +if (bs-io_limits_enabled) { +bdrv_io_limits_enable(bs); +} + return 0; unlink_and_fail: @@ -754,6 +815,9 @@ void bdrv_close(BlockDriverState *bs) bdrv_dev_change_media_cb(bs, false); } + +/*throttling disk I/O limits*/ +bdrv_io_limits_disable(bs); } void bdrv_close_all(void) @@ -1292,6 +1356,11 @@ static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs, return -EIO; } +/* throttling disk read I/O */ +if (bs-io_limits_enabled) { +bdrv_io_limits_intercept(bs, nb_sectors); +} + return drv-bdrv_co_readv(bs, sector_num, nb_sectors, qiov); } @@ -1322,6 +1391,11 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs, return -EIO; } +/* throttling disk write I/O */ +if (bs-io_limits_enabled) { +bdrv_io_limits_intercept(bs, nb_sectors); +} + ret = drv-bdrv_co_writev(bs, sector_num, nb_sectors, qiov); if (bs-dirty_bitmap) { @@ -2513,6 +2587,160 @@ void bdrv_aio_cancel(BlockDriverAIOCB *acb) acb-pool-cancel(acb); } +/* block I/O throttling */ +static bool bdrv_exceed_bps_limits(BlockDriverState *bs, int nb_sectors, + bool is_write, double elapsed_time, uint64_t *wait) { +uint64_t bps_limit = 0; +double bytes_limit, bytes_disp, bytes_res; +double slice_time, wait_time; + +if (bs-io_limits.bps[BLOCK_IO_LIMIT_TOTAL]) { +bps_limit = bs-io_limits.bps[BLOCK_IO_LIMIT_TOTAL]; +} else if (bs-io_limits.bps[is_write]) { +bps_limit = bs-io_limits.bps[is_write]; +} else { +if (wait) { +*wait = 0; +} + +return false; +} + +slice_time = bs-slice_end - bs-slice_start; +slice_time /= (NANOSECONDS_PER_SECOND); +bytes_limit = bps_limit * slice_time; +bytes_disp = bs-nr_bytes[is_write] -
[Qemu-devel] [PATCH v10 3/3] hmp/qmp: add block_set_io_throttle
Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com --- block.c | 15 +++ blockdev.c | 51 +++ blockdev.h |2 ++ hmp-commands.hx | 15 +++ hmp.c| 10 ++ qapi-schema.json | 16 +++- qerror.c |4 qerror.h |3 +++ qmp-commands.hx | 53 - 9 files changed, 167 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index cb89372..7d856c2 100644 --- a/block.c +++ b/block.c @@ -1976,6 +1976,21 @@ BlockInfoList *qmp_query_block(Error **errp) info-value-inserted-has_backing_file = true; info-value-inserted-backing_file = g_strdup(bs-backing_file); } + +if (bs-io_limits_enabled) { +info-value-inserted-bps = + bs-io_limits.bps[BLOCK_IO_LIMIT_TOTAL]; +info-value-inserted-bps_rd = + bs-io_limits.bps[BLOCK_IO_LIMIT_READ]; +info-value-inserted-bps_wr = + bs-io_limits.bps[BLOCK_IO_LIMIT_WRITE]; +info-value-inserted-iops = + bs-io_limits.iops[BLOCK_IO_LIMIT_TOTAL]; +info-value-inserted-iops_rd = + bs-io_limits.iops[BLOCK_IO_LIMIT_READ]; +info-value-inserted-iops_wr = + bs-io_limits.iops[BLOCK_IO_LIMIT_WRITE]; +} } /* XXX: waiting for the qapi to support GSList */ diff --git a/blockdev.c b/blockdev.c index faf8c56..9eed973 100644 --- a/blockdev.c +++ b/blockdev.c @@ -745,6 +745,57 @@ int do_change_block(Monitor *mon, const char *device, return monitor_read_bdrv_key_start(mon, bs, NULL, NULL); } +/* throttling disk I/O limits */ +int do_block_set_io_throttle(Monitor *mon, + const QDict *qdict, QObject **ret_data) +{ +const char *devname = qdict_get_str(qdict, device); +int64_t bps= qdict_get_try_int(qdict, bps, -1); +int64_t bps_rd = qdict_get_try_int(qdict, bps_rd, -1); +int64_t bps_wr = qdict_get_try_int(qdict, bps_wr, -1); +int64_t iops = qdict_get_try_int(qdict, iops, -1); +int64_t iops_rd= qdict_get_try_int(qdict, iops_rd, -1); +int64_t iops_wr= qdict_get_try_int(qdict, iops_wr, -1); +BlockDriverState *bs; + +bs = bdrv_find(devname); +if (!bs) { +qerror_report(QERR_DEVICE_NOT_FOUND, devname); +return -1; +} + +if ((bps == -1) || (bps_rd == -1) || (bps_wr == -1) +|| (iops == -1) || (iops_rd == -1) || (iops_wr == -1)) { +qerror_report(QERR_MISSING_PARAMETER, + bps/bps_rd/bps_wr/iops/iops_rd/iops_wr); +return -1; +} + +if ((bps != 0 (bps_rd != 0 || bps_wr != 0)) +|| (iops != 0 (iops_rd != 0 || iops_wr != 0))) { +qerror_report(QERR_INVALID_PARAMETER_COMBINATION); +return -1; +} + +bs-io_limits.bps[BLOCK_IO_LIMIT_TOTAL] = bps; +bs-io_limits.bps[BLOCK_IO_LIMIT_READ] = bps_rd; +bs-io_limits.bps[BLOCK_IO_LIMIT_WRITE] = bps_wr; +bs-io_limits.iops[BLOCK_IO_LIMIT_TOTAL] = iops; +bs-io_limits.iops[BLOCK_IO_LIMIT_READ] = iops_rd; +bs-io_limits.iops[BLOCK_IO_LIMIT_WRITE] = iops_wr; +bs-slice_time = BLOCK_IO_SLICE_TIME; + +if (!bs-io_limits_enabled bdrv_io_limits_enabled(bs)) { +bdrv_io_limits_enable(bs); +} else if (bs-io_limits_enabled !bdrv_io_limits_enabled(bs)) { +bdrv_io_limits_disable(bs); +} else { +qemu_mod_timer(bs-block_timer, qemu_get_clock_ns(vm_clock)); +} + +return 0; +} + int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) { const char *id = qdict_get_str(qdict, id); diff --git a/blockdev.h b/blockdev.h index 3587786..1b48a75 100644 --- a/blockdev.h +++ b/blockdev.h @@ -63,6 +63,8 @@ int do_block_set_passwd(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_change_block(Monitor *mon, const char *device, const char *filename, const char *fmt); int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data); +int do_block_set_io_throttle(Monitor *mon, + const QDict *qdict, QObject **ret_data); int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_block_resize(Monitor *mon, const QDict *qdict, QObject **ret_data); diff --git a/hmp-commands.hx b/hmp-commands.hx index 089c1ac..48f3c21 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1207,6 +1207,21 @@ ETEXI }, STEXI +@item block_set_io_throttle @var{device} @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr} +@findex block_set_io_throttle +Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd} @var{bps_wr} @var{iops}
Re: [Qemu-devel] [PATCH v9 1/4] block: add the block queue support
On Mon, Oct 31, 2011 at 9:35 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Fri, Oct 28, 2011 at 11:02 AM, Zhi Yong Wu wu...@linux.vnet.ibm.com wrote: +static void bdrv_io_limits_skip_set(void *opaque, + BlockAPIType co_type, + bool cb_skip, + bool limit_skip) { + RwCo *rwco; + BlockDriverAIOCBCoroutine *aioco; + + if (co_type == BDRV_API_SYNC) { + rwco = opaque; + rwco-limit_skip = limit_skip; + } else if (co_type == BDRV_API_ASYNC) { + aioco = opaque; + aioco-cb_skip = cb_skip; + aioco-limit_skip = limit_skip; + } else { + abort(); + } +} I have sent out v10. It discard the queue and request defined by us, and rebase it to CoQueue, and let Coroutine represent one I/O request. The code logic is now much simpler. The main question I have about this series is why have different cases for sync, aio, and coroutines? Perhaps I'm missing something but this should all be much simpler. All read/write requests are processed in a coroutine (bdrv_co_do_readv()/bdrv_co_do_writev()). That is the place to perform I/O throttling. Throttling should not be aware of sync, aio, vs coroutines. Since all requests have coroutines you could use CoQueue and the actual queue waiting code in bdrv_co_do_readv()/bdrv_co_do_writev() becomes: if (bdrv_exceeds_io_limit(bs, sector_num, qiov, is_write)) { qemu_co_queue_wait(bs-throttled_reqs); /* Wait until this request is allowed to start */ while (bdrv_exceeds_io_limit(bs, sector_num, qiov, is_write)) { /* Re-inserting at the head of the CoQueue is equivalent to * the queue-flushing/queue-limit_exceeded behavior in your * patch. */ qemu_co_queue_wait_insert_head(bs-throttled_reqs); } } I think block/blk-queue.h isn't needed if you use the existing CoQueue structure. This is the main point I want to raise, just a few minor comments below which may not be relevant if you can drop BlockQueue. +static int qemu_block_queue_handler(BlockQueueAIOCB *request) +{ + int ret; + + BlockDriverState *bs = request-common.bs; + assert(bs); + + if (bs-io_limits_enabled) { I'm not sure why the BlockQueue needs to reach into BlockDriverState. Now BlockDriverState and BlockQueue know about and depend on each other. It's usually nicer to keep the relationship unidirectional, if possible. + ret = request-handler(request-common.bs, request-sector_num, + request-nb_sectors, request-qiov, + request, request-co_type); + } else { + if (request-co_type == BDRV_API_CO) { + qemu_coroutine_enter(request-co, request-cocb); + } else { + printf(%s, req: %p\n, __func__, (void *)request); Debug output should be removed. + bdrv_io_limits_issue_request(request, request-co_type); + } + + ret = BDRV_BLKQ_DEQ_PASS; + } + + return ret; +} + +void qemu_block_queue_submit(BlockQueue *queue, BlockDriverCompletionFunc *cb) +{ + BlockQueueAIOCB *request; + queue-flushing = true; + + /*QTAILQ_FOREACH_SAFE(request, queue-requests, entry, next) {*/ Commented out code should be removed. + while (!QTAILQ_EMPTY(queue-requests)) { + int ret = 0; + + request = QTAILQ_FIRST(queue-requests); + QTAILQ_REMOVE(queue-requests, request, entry); + queue-limit_exceeded = false; + ret = qemu_block_queue_handler(request); + if (ret == -EIO) { + cb(request, -EIO); + break; + } else if (ret == BDRV_BLKQ_ENQ_AGAIN) { + QTAILQ_INSERT_HEAD(queue-requests, request, entry); + break; + } else if (ret == BDRV_BLKQ_DEQ_PASS) { + cb(request, 0); + } What if ret is not -EIO, BDRV_BLKQ_ENQ_AGAIN, or BDRV_BLKQ_DEQ_PASS? I think the -EIO case should be the default that calls cb(request, ret). + } + + printf(%s, leave\n, __func__); Debug code should be removed. Stefan -- Regards, Zhi Yong Wu
[Qemu-devel] buildbot failure in qemu on s390-next_i386_debian_6_0
The Buildbot has detected a new failure on builder s390-next_i386_debian_6_0 while building qemu. Full details are available at: http://buildbot.b1-systems.de/qemu/builders/s390-next_i386_debian_6_0/builds/79 Buildbot URL: http://buildbot.b1-systems.de/qemu/ Buildslave for this Build: yuzuki Build Reason: The Nightly scheduler named 'nightly_s390-next' triggered this build Build Source Stamp: [branch s390-next] HEAD Blamelist: BUILD FAILED: failed git sincerely, -The Buildbot
[Qemu-devel] [PATCH v2] qed: adjust the way to get nb_sectors
This patch is only to refactor some lines of codes to get better and more robust codes. As you have seen, in qed_read_table_cb() it's nice to use qiov-size because that function doesn't obviously use a single struct iovec. In other two functions, if qiov use more than one struct iovec, the existing way will get wrong nb_sectors. To make the code more robust, it will be nicer to refactor the existing way as below. Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com --- block/qed-table.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/block/qed-table.c b/block/qed-table.c index f31f9ff..8ee8443 100644 --- a/block/qed-table.c +++ b/block/qed-table.c @@ -29,7 +29,7 @@ static void qed_read_table_cb(void *opaque, int ret) { QEDReadTableCB *read_table_cb = opaque; QEDTable *table = read_table_cb-table; -int noffsets = read_table_cb-iov.iov_len / sizeof(uint64_t); +int noffsets = read_table_cb-qiov.size / sizeof(uint64_t); int i; /* Handle I/O error */ @@ -65,7 +65,7 @@ static void qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, qemu_iovec_init_external(qiov, read_table_cb-iov, 1); aiocb = bdrv_aio_readv(s-bs-file, offset / BDRV_SECTOR_SIZE, qiov, - read_table_cb-iov.iov_len / BDRV_SECTOR_SIZE, + qiov-size / BDRV_SECTOR_SIZE, qed_read_table_cb, read_table_cb); if (!aiocb) { qed_read_table_cb(read_table_cb, -EIO); @@ -160,7 +160,7 @@ static void qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, aiocb = bdrv_aio_writev(s-bs-file, offset / BDRV_SECTOR_SIZE, write_table_cb-qiov, -write_table_cb-iov.iov_len / BDRV_SECTOR_SIZE, +write_table_cb-qiov.size / BDRV_SECTOR_SIZE, qed_write_table_cb, write_table_cb); if (!aiocb) { qed_write_table_cb(write_table_cb, -EIO); -- 1.7.6
Re: [Qemu-devel] buildbot failure in qemu on xen_x86_64_debian_6_0
Hi Stefan, On Tuesday, November 01, 2011 08:36:46 AM Stefan Weil wrote: As far as I know from previous mails, the buildbots already do a retry when git fails. The retry period used today is obviously too short. i finally took a closer look on this failed git reports. It seems like all the git failed mails are not due to a too short reply period. It is due to the buildslave version used on yuzuki is not recent enough to perform retries at all. Other buildslaves which have buildbot version 0.8.2 and greater perform retries correctly and seem to require only one retry to finally succeed. yuzuki is running buildbot version 0.7.12 and doesn't perform any retry and cause nearly all git failed mails since we introduced git-fetch retries. Stefan, could you update your buildslave yuzuki? In meanwhile I try to setup mine buildslave also with a new version of buildbot. Best Regards, Daniel -- Daniel Gollub Linux Consultant Developer Tel.: +49-160 47 73 970 Mail: gol...@b1-systems.de B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 signature.asc Description: This is a digitally signed message part.
Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin
On Oct 31, 2011, at 3:18 PM, Andreas Färber wrote: In file included from ./bswap.h:7, from ./qemu-common.h:106, from ./qemu-aio.h:17, from ./Block.h:4, from /System/Library/Frameworks/ CoreServices.framework/Frameworks/CarbonCore.framework/Headers/ FSEvents.h:28, from /System/Library/Frameworks/ CoreServices.framework/Frameworks/CarbonCore.framework/Headers/ CarbonCore.h:218, from /System/Library/Frameworks/ CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20, from /System/Library/Frameworks/ CoreServices.framework/Headers/CoreServices.h:21, from /System/Library/Frameworks/Foundation.framework/ Headers/NSURLError.h:17, from /System/Library/Frameworks/Foundation.framework/ Headers/Foundation.h:81, from /System/Library/Frameworks/Cocoa.framework/ Headers/Cocoa.h:12, from ui/cocoa.m:25: /Users/andreas/QEMU/qemu/fpu/softfloat.h:60: error: conflicting types for ‘uint16’ /System/Library/Frameworks/Security.framework/Headers/cssmconfig.h: 73: error: previous declaration of ‘uint16’ was here make: *** [ui/cocoa.o] Error 1 Apple's FSEvents.h has #include Block.h, which wants /usr/include/Block.h but due to case-insensitive file system and include path jungle gets QEMU's ./block.h, which in turn includes softfloat.h indirectly. Therefore work around the conflict in softfloat.h itself by renaming specifically uint16 on Darwin to qemu_uint16. This fixes the build until we have a more general solution. Signed-off-by: Andreas Färber andreas.faer...@web.de Cc: Juan Pineda j...@logician.com Cc: Peter Maydell peter.mayd...@linaro.org --- fpu/softfloat.h |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/fpu/softfloat.h b/fpu/softfloat.h index 07c2929..5320945 100644 --- a/fpu/softfloat.h +++ b/fpu/softfloat.h @@ -54,6 +54,9 @@ these four paragraphs for those parts of this code that are retained. | to the same as `int'. **/ typedef uint8_t flag; +#ifdef __APPLE__ +#define uint16 qemu_uint16 +#endif typedef uint8_t uint8; typedef int8_t int8; #ifndef _AIX Perhaps the following alternative solution would be more palatable? It's still tremendously ugly, but is localized to cocoa.m, thus less intrusive. -- 8 -- Subject: [PATCH] softfloat: Avoid uint16 type conflict on Darwin cocoa.m includes Security/cssmconfig.h indirectly via Cocoa/Cocoa.h. cssmconfig.h defines type uint16 which unfortunately conflicts with the definition in qemu's softfloat.h, thus resulting in compilation failure. To work around the problem, #define _UINT16, which informs cssmconfig.h that uint16 is already defined and that it should not apply its own definition. Additionally, ensure that Cocoa/Cocoa.h is included after softfloat.h rather than before since some Cocoa headers expect type uint16 to exist. Signed-off-by: Eric Sunshine sunsh...@sunshineco.com --- ui/cocoa.m |7 --- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index d9e4e3d..ac15418 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -22,13 +22,14 @@ * THE SOFTWARE. */ -#import Cocoa/Cocoa.h -#include crt_externs.h - #include qemu-common.h #include console.h #include sysemu.h +#define _UINT16 +#import Cocoa/Cocoa.h +#include crt_externs.h + #ifndef MAC_OS_X_VERSION_10_4 #define MAC_OS_X_VERSION_10_4 1040 #endif -- 1.7.7.1
Re: [Qemu-devel] [patch] explicitly initialize tcg_cpu_thread
On Tue, Nov 1, 2011 at 3:06 PM, Pavel Borzenkov pavel.borzen...@gmail.com wrote: On Tue, Nov 1, 2011 at 7:35 AM, Jun Koi junkoi2...@gmail.com wrote: This patch explicitly initializes tcg_cpu_thread to NULL in cpus.c (One code patch in qemu_tcg_init_vcpu() relies on the value of tcg_cpu_thread to create env-thread and so on ) Signed-off-by: Jun Koi junkoi2...@gmail.com You don't need to explicitly initialize objects with static storage duration. They are initialized to NULL/0 implicitly. This is guaranteed by the C standard. that is good to know, but i think that is better safe than sorry. what if we compile Qemu with a compiler that doesnt follow the standard? also, i remember that we always initialize static vars? or am i wrong? thanks, Jun diff --git a/cpus.c b/cpus.c index f768683..47feb58 100644 --- a/cpus.c +++ b/cpus.c @@ -606,7 +606,7 @@ static bool iothread_requesting_mutex; static QemuThread io_thread; -static QemuThread *tcg_cpu_thread; +static QemuThread *tcg_cpu_thread = NULL; static QemuCond *tcg_halt_cond; /* cpu creation */
Re: [Qemu-devel] [PULL 0/3] 128-bit support for the memory API
On 11/01/2011 02:54 AM, David Gibson wrote: On Mon, Oct 31, 2011 at 11:05:47AM -0500, Anthony Liguori wrote: On 10/30/2011 09:02 AM, Avi Kivity wrote: This somewhat controversial patchset converts internal arithmetic in the memory API to 128 bits. Given the level of controversy, what do you think about deferring this to 1.1? If it's deferred then one of my rearrangements for the arithmetic must go in instead. These patches fix real bugs, that bite us on pseries. It's not the only way to fix those bugs, and probably not even my personally preferred way to fix them, but they need to be fixed _somehow_ for 1.0. Yes, plus if one of them is exploitable, then it's certainly a must for 1.0. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.
Re: [Qemu-devel] [PATCH] pci: add standard bridge device
At 11/01/2011 04:44 PM, Michael S. Tsirkin Write: On Tue, Nov 01, 2011 at 09:27:25AM +0800, Wen Congyang wrote: Hi, Michael S. Tsirkin At 09/26/2011 03:08 PM, Michael S. Tsirkin Write: On Mon, Sep 26, 2011 at 02:18:15PM +0800, Wen Congyang wrote: Hi, Michael S. Tsirkin At 07/04/2011 05:43 PM, Michael S. Tsirkin Write: This adds support for a standard pci to pci bridge, enabling support for more than 32 PCI devices in the system. To use, specify the device id as a 'bus' option. Example: -device pci-bridge,id=bridge1 \ -netdev user,id=u \ -device ne2k_pci,id=net2,bus=bridge1,netdev=u TODO: device hotplug support. Do you have any plan to implement this? I think this will be needed before merging the bridge code. What will you plan to support? 1. all PCI-to-PCI bridge is not hotpluggable. host bridge | - | | bridgebridge = *not* hotpluggable | | --- | | || slot slot slot slot = hotplug here 2. PCI-to-PCI bridge is hotpluggable. bridge | --- | | bridge on slot bridge on slot = hot-plug here | | --- --- | | | | slot slot slot slot= hot-plug here I read the qemu's code, and find that qemu uses PIIX4_PM to support pci device hot plugging on PCI bus 0. How to support it on the other bus? Add PIIX4_PM to each PCI bus or implement a new power management? Thanks Wen Congyang There are many valid options. One is shpc interface. I started looking into this but got preempted by other tasks. Hope to get back to this at some point. Some old OS does not support shpc. So I think it's better to use ACPI to do it. Currently, we get which device is removed or inserted by reading the I/O port 0xae00(length: 8 bytes), and _EJ0 method uses I/O port 0xae08(length: 4 bytes). How do we determine this I/O address? Is there any spec to describe it? Thanks Wen Congyang Can we discuss these questions on the mailing list? No problem. I have cced qemu mailing list. Thanks Wen Congyang
[Qemu-devel] [patch] remove dead code, and make cpu_exec_all() static
This patch removes dead code (kvm related) in cpu_exec_all(), and makes that static (since nobody uses it) Signed-off-by: Jun Koi junkoi2...@gmail.com diff --git a/cpus.c b/cpus.c index f768683..77282a1 100644 --- a/cpus.c +++ b/cpus.c @@ -85,6 +85,8 @@ typedef struct TimersState { TimersState timers_state; +static bool cpu_exec_all(void); + /* Return the virtual CPU time, based on the instruction counter. */ int64_t cpu_get_icount(void) { @@ -1016,7 +1018,7 @@ static int tcg_cpu_exec(CPUState *env) return ret; } -bool cpu_exec_all(void) +static bool cpu_exec_all(void) { int r; @@ -1033,12 +1035,7 @@ bool cpu_exec_all(void) (env-singlestep_enabled SSTEP_NOTIMER) == 0); if (cpu_can_run(env)) { -if (kvm_enabled()) { -r = kvm_cpu_exec(env); -qemu_kvm_eat_signals(env); -} else { -r = tcg_cpu_exec(env); -} +r = tcg_cpu_exec(env); if (r == EXCP_DEBUG) { cpu_handle_guest_debug(env); break; diff --git a/cpus.h b/cpus.h index 3525375..4ea2fe2 100644 --- a/cpus.h +++ b/cpus.h @@ -14,7 +14,6 @@ void cpu_synchronize_all_post_init(void); /* vl.c */ extern int smp_cores; extern int smp_threads; -bool cpu_exec_all(void); void set_numa_modes(void); void set_cpu_log(const char *optarg); void set_cpu_log_filename(const char *optarg);
Re: [Qemu-devel] [PATCH 1/2] Allow 1366x768 as a valid VGA resolution
On 10/28/11 21:24, John Baboval wrote: 760p TV panels have a 1366x768 resolution, and have been popular recently as low-cost monitors. The 1366 resolution doesn't pass the (xres 7) == 0 test. Why is it save to simply remove the test? Guess there is a reason why it is there in the first place? cheers, Gerd
Re: [Qemu-devel] [PATCH 2/2] Variable VRAM size
On 10/28/11 21:24, John Baboval wrote: High resolution VGA modes require more than the default 8MB of VGA RAM. Add a command line parameter to allow larger sizes. This should be implemented as (qdev) device property. cheers, Gerd
Re: [Qemu-devel] [PATCH v2] qed: adjust the way to get nb_sectors
On Tue, Nov 1, 2011 at 8:04 AM, Zhi Yong Wu wu...@linux.vnet.ibm.com wrote: This patch is only to refactor some lines of codes to get better and more robust codes. As you have seen, in qed_read_table_cb() it's nice to use qiov-size because that function doesn't obviously use a single struct iovec. In other two functions, if qiov use more than one struct iovec, the existing way will get wrong nb_sectors. To make the code more robust, it will be nicer to refactor the existing way as below. Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com --- block/qed-table.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Acked-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
Re: [Qemu-devel] [patch] explicitly initialize tcg_cpu_thread
On Tue, Nov 1, 2011 at 12:33 PM, Jun Koi junkoi2...@gmail.com wrote: On Tue, Nov 1, 2011 at 3:06 PM, Pavel Borzenkov pavel.borzen...@gmail.com wrote: On Tue, Nov 1, 2011 at 7:35 AM, Jun Koi junkoi2...@gmail.com wrote: This patch explicitly initializes tcg_cpu_thread to NULL in cpus.c (One code patch in qemu_tcg_init_vcpu() relies on the value of tcg_cpu_thread to create env-thread and so on ) Signed-off-by: Jun Koi junkoi2...@gmail.com You don't need to explicitly initialize objects with static storage duration. They are initialized to NULL/0 implicitly. This is guaranteed by the C standard. that is good to know, but i think that is better safe than sorry. what if we compile Qemu with a compiler that doesnt follow the standard? also, i remember that we always initialize static vars? or am i wrong? No, we don't. checkpatch.pl has a check to ensure that static variables are not explicitly initialized to NULL. Try to check your patch with this script. It will throw an error: {{{ ERROR: do not initialise statics to 0 or NULL #80: FILE: cpus.c:609: +static QemuThread *tcg_cpu_thread = NULL; total: 1 errors, 0 warnings, 8 lines checked }}} -- Pavel thanks, Jun diff --git a/cpus.c b/cpus.c index f768683..47feb58 100644 --- a/cpus.c +++ b/cpus.c @@ -606,7 +606,7 @@ static bool iothread_requesting_mutex; static QemuThread io_thread; -static QemuThread *tcg_cpu_thread; +static QemuThread *tcg_cpu_thread = NULL; static QemuCond *tcg_halt_cond; /* cpu creation */
Re: [Qemu-devel] [PATCH] hw/9pfs: use g_vasprintf() instead of rolling our own
On Mon, Oct 31, 2011 at 11:28:45PM +0530, Aneesh Kumar K.V wrote: On Mon, 31 Oct 2011 11:49:33 +, Stefan Hajnoczi stefa...@linux.vnet.ibm.com wrote: Markus Armbruster arm...@redhat.com sent fixes for va_list vararg issues in v9fs_string_alloc_printf(). It turns out the function duplicates g_vasprintf() and can therefore be eliminated entirely. Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com Reviewed-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Do you want to take this into your 9pfs tree? Stefan
Re: [Qemu-devel] [PATCH v2] use g_free, instead of free
On Tue, Nov 01, 2011 at 02:21:53PM +0800, Dong Xu Wang wrote: From: Dong Xu Wang wdon...@linux.vnet.ibm.com Fix mismatching allocation and deallocation: g_free should be used to pair with g_malloc. Also fix coding style. Signed-off-by: Dong Xu Wang wdon...@linux.vnet.ibm.com --- block/cloop.c | 119 +++-- 1 files changed, 65 insertions(+), 54 deletions(-) Kevin: Please consider this for the block tree. Stefan
Re: [Qemu-devel] [PATCH] block.c typo in comment fixed
On Tue, Nov 01, 2011 at 01:36:42AM +, matthias@googlemail.com wrote: From: Matthias Brugger matthias@gmail.com Signed-off-by: Matthias Brugger matthias@gmail.com --- block.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) Writable is also a common spelling. Try git grep writable and compare against git grep writeable. In qemu.git writable actually dominates by a large majority so we should leave this alone. Stefan
Re: [Qemu-devel] [PATCH v3 1/4] Add basic version of bridge helper
On Mon, Oct 31, 2011 at 02:36:28PM -0400, Corey Bryant wrote: A couple of nitpicks regarding error handling: +static int has_vnet_hdr(int fd) +{ +unsigned int features = 0; +struct ifreq ifreq; + +if (ioctl(fd, TUNGETFEATURES, features) == -1) { +return -errno; +} + +if (!(features IFF_VNET_HDR)) { +return -ENOTSUP; +} + +if (ioctl(fd, TUNGETIFF, ifreq) != -1 || errno != EBADFD) { +return -ENOTSUP; +} + +return 1; +} This function is strange, it looks like a boolean function but actually only returns 1 or -errno. It is used incorrectly in main(). I suggest changing the return value to bool and returning false on error. +/* open a socket to use to control the network interfaces */ +ctlfd = socket(AF_INET, SOCK_STREAM, 0); +if (ctlfd == -1) { +fprintf(stderr, failed to open control socket\n); +ret = -errno; It's better to stash away errno before invoking other library functions. man errno(3) says: a function that succeeds is allowed to change errno This means fprintf(3) could clobber errno. I suggest simply printing out errno with the error message and returning exit code 1 (EXIT_FAILURE). The same applies for the other error exit cases in main(). +cleanup: + +close(fd); + +close(ctlfd); ctlfd is an uninitialized variable if opening fd fails. We also never close unixfd. I'd remove this cleanup code and just return without closing any file descriptors - let the kernel do it. Stefan
Re: [Qemu-devel] Performance of USB2.0
Hi, This means that the likely cause is just that usb emulation / pass through causes quite a bit of overhead, which is not unexpected since both the usb protocol and the ehci controller interface are both quite hard to emulate. I think the main issue here is that we don't do buffering / pipelining for bulk transfers at the moment. We grab a single transfer request from the guest, pass it to the kernel, when it is done pass it back to the guest, then look look for the next one. Instead we could queue up all transfer requests from the guest to the kernel, which would give a noticable better throughput. The qemu usb subsystem can't handle that (yet). Fixing that is one the TODO list though. Additionally all bulk xfer processing is done in the 1000 Hz frame timer, which combined with the above limits the number of packets to 1000 packets per second (and direction), i.e. with a MTU of 1500 you'll get 1500 * 1000 = 1.5 MB/s max. This you can expect to get with the current code. Add some protocol and other overhead to the 7 MBit/s you are actually seeing and the numbers are pretty close, so there isn't much room to improve things. The only option I see is to operate the device with an larger MTU if the usb device and your network setup can handle that. HTH, Gerd
[Qemu-devel] [PATCH] qemu-barrier: Fix build failure on PowerPC Mac OS X
qemu-barrier.h tests if macro __powerpc__ is defined, however, the preprocessor on PowerPC Mac OS X defines only __POWERPC__, not __powerpc__. Resolve by testing instead for qemu-provided _ARCH_PPC. Signed-off-by: Eric Sunshine sunsh...@sunshineco.com --- The anomalous __powerpc__ test appears only in qemu-barrier.h. No other source files reference this name. Cc: David Gibson da...@gibson.dropbear.id.au qemu-barrier.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/qemu-barrier.h b/qemu-barrier.h index 735eea6..c11bb2b 100644 --- a/qemu-barrier.h +++ b/qemu-barrier.h @@ -14,7 +14,7 @@ */ #define smp_wmb() barrier() -#elif defined(__powerpc__) +#elif defined(_ARCH_PPC) /* * We use an eieio() for a wmb() on powerpc. This assumes we don't -- 1.7.7.1
Re: [Qemu-devel] [PATCH v2] use g_free, instead of free
Am 01.11.2011 07:21, schrieb Dong Xu Wang: From: Dong Xu Wang wdon...@linux.vnet.ibm.com Fix mismatching allocation and deallocation: g_free should be used to pair with g_malloc. Also fix coding style. Signed-off-by: Dong Xu Wang wdon...@linux.vnet.ibm.com I took the time to go through the changes. Me, I would've preferred this to be two patches (one cleanup, one fix), since the style changes make up the majority of this patch... Two style changes are missing for perfection, cf. inline. Changelog is missing. Did just the description change since v1? In that case Ray Wang's Reviewed-by is missing. Otherwise please describe! Trusting Ray that g_free() was right in the first place, Reviewed-by: Andreas Färber afaer...@suse.de --- block/cloop.c | 119 +++-- 1 files changed, 65 insertions(+), 54 deletions(-) diff --git a/block/cloop.c b/block/cloop.c index 775f8a9..1884b8c 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -74,26 +76,28 @@ static int cloop_open(BlockDriverState *bs, int flags) s-offsets = g_malloc(offsets_size); if (bdrv_pread(bs-file, 128 + 4 + 4, s-offsets, offsets_size) offsets_size) { - goto cloop_close; +goto cloop_close; } for(i=0;is-n_blocks;i++) { - s-offsets[i]=be64_to_cpu(s-offsets[i]); - if(i0) { - uint32_t size=s-offsets[i]-s-offsets[i-1]; - if(sizemax_compressed_block_size) - max_compressed_block_size=size; - } +s-offsets[i] = be64_to_cpu(s-offsets[i]); +if (i 0) { +uint32_t size = s-offsets[i] - s-offsets[i-1]; i - 1 theoretically +if (size max_compressed_block_size) { +max_compressed_block_size = size; +} +} } /* initialize zlib engine */ -s-compressed_block = g_malloc(max_compressed_block_size+1); +s-compressed_block = g_malloc(max_compressed_block_size + 1); s-uncompressed_block = g_malloc(s-block_size); -if(inflateInit(s-zstream) != Z_OK) - goto cloop_close; -s-current_block=s-n_blocks; +if (inflateInit(s-zstream) != Z_OK) { +goto cloop_close; +} +s-current_block = s-n_blocks; s-sectors_per_block = s-block_size/512; -bs-total_sectors = s-n_blocks*s-sectors_per_block; +bs-total_sectors = s-n_blocks * s-sectors_per_block; qemu_co_mutex_init(s-lock); return 0; @@ -105,27 +109,30 @@ static inline int cloop_read_block(BlockDriverState *bs, int block_num) { BDRVCloopState *s = bs-opaque; -if(s-current_block != block_num) { - int ret; -uint32_t bytes = s-offsets[block_num+1]-s-offsets[block_num]; +if (s-current_block != block_num) { +int ret; +uint32_t bytes = s-offsets[block_num + 1]-s-offsets[block_num]; ] - s ret = bdrv_pread(bs-file, s-offsets[block_num], s-compressed_block, bytes); -if (ret != bytes) +if (ret != bytes) { return -1; +} + +s-zstream.next_in = s-compressed_block; +s-zstream.avail_in = bytes; +s-zstream.next_out = s-uncompressed_block; +s-zstream.avail_out = s-block_size; +ret = inflateReset(s-zstream); +if (ret != Z_OK) { +return -1; +} +ret = inflate(s-zstream, Z_FINISH); +if (ret != Z_STREAM_END || s-zstream.total_out != s-block_size) { +return -1; +} - s-zstream.next_in = s-compressed_block; - s-zstream.avail_in = bytes; - s-zstream.next_out = s-uncompressed_block; - s-zstream.avail_out = s-block_size; - ret = inflateReset(s-zstream); - if(ret != Z_OK) - return -1; - ret = inflate(s-zstream, Z_FINISH); - if(ret != Z_STREAM_END || s-zstream.total_out != s-block_size) - return -1; - - s-current_block = block_num; +s-current_block = block_num; } return 0; } @@ -160,20 +170,21 @@ static coroutine_fn int cloop_co_read(BlockDriverState *bs, int64_t sector_num, static void cloop_close(BlockDriverState *bs) { BDRVCloopState *s = bs-opaque; -if(s-n_blocks0) - free(s-offsets); -free(s-compressed_block); -free(s-uncompressed_block); +if (s-n_blocks 0) { +g_free(s-offsets); +} +g_free(s-compressed_block); +g_free(s-uncompressed_block); Here are the 3 functional changes! inflateEnd(s-zstream); } static BlockDriver bdrv_cloop = { -.format_name = cloop, -.instance_size = sizeof(BDRVCloopState), -.bdrv_probe = cloop_probe, -.bdrv_open = cloop_open, -.bdrv_read = cloop_co_read, -.bdrv_close = cloop_close, +.format_name= cloop, +.instance_size = sizeof(BDRVCloopState), +.bdrv_probe =
Re: [Qemu-devel] [PATCH v2 0/3] Misc small fixes in cmd.c
On Mon, Oct 31, 2011 at 10:53:35PM +0400, Pavel Borzenkov wrote: The first patch fixes coding style of the functions affected by next two patches. Second patch fixes potential NULL pointer dereference (return value of realloc is not checked). Third patch fixes potential memory leak (for the case when realloc returns NULL). Pavel Borzenkov (3): cmd: Fix coding style in cmd.c cmd: Fix potential NULL pointer dereference cmd: Fix potential memory leak cmd.c | 168 - 1 files changed, 82 insertions(+), 86 deletions(-) Thanks, applied to the trivial patches -next tree: http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches-next Stefan
Re: [Qemu-devel] [PATCH] Simplify cpu_exec_all to tcg_exec_all
i have sent a patch, which duplicated the function of this patch. this one was not approved yet?? thanks, Jun On Mon, Sep 26, 2011 at 3:40 PM, Jan Kiszka jan.kis...@siemens.com wrote: After the removal of the non-threaded mode cpu_exec_all is now only used by TCG. Refactor it accordingly, also dropping its unused return value. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- cpus.c | 14 +- cpus.h | 1 - 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/cpus.c b/cpus.c index 8978779..f983033 100644 --- a/cpus.c +++ b/cpus.c @@ -664,6 +664,8 @@ static void *qemu_kvm_cpu_thread_fn(void *arg) return NULL; } +static void tcg_exec_all(void); + static void *qemu_tcg_cpu_thread_fn(void *arg) { CPUState *env = arg; @@ -685,7 +687,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) } while (1) { - cpu_exec_all(); + tcg_exec_all(); if (use_icount qemu_next_icount_deadline() = 0) { qemu_notify_event(); } @@ -925,7 +927,7 @@ static int tcg_cpu_exec(CPUState *env) return ret; } -bool cpu_exec_all(void) +static void tcg_exec_all(void) { int r; @@ -942,12 +944,7 @@ bool cpu_exec_all(void) (env-singlestep_enabled SSTEP_NOTIMER) == 0); if (cpu_can_run(env)) { - if (kvm_enabled()) { - r = kvm_cpu_exec(env); - qemu_kvm_eat_signals(env); - } else { - r = tcg_cpu_exec(env); - } + r = tcg_cpu_exec(env); if (r == EXCP_DEBUG) { cpu_handle_guest_debug(env); break; @@ -957,7 +954,6 @@ bool cpu_exec_all(void) } } exit_request = 0; - return !all_cpu_threads_idle(); } void set_numa_modes(void) diff --git a/cpus.h b/cpus.h index 5885885..bb91684 100644 --- a/cpus.h +++ b/cpus.h @@ -15,7 +15,6 @@ void cpu_synchronize_all_post_init(void); /* vl.c */ extern int smp_cores; extern int smp_threads; -bool cpu_exec_all(void); void set_numa_modes(void); void set_cpu_log(const char *optarg); void set_cpu_log_filename(const char *optarg); -- 1.7.3.4
Re: [Qemu-devel] GSoC mentor summit QEMU users session
Hi, If we get the qdev rework done then I think we're probably in a better position to have a plugin framework for devices. (There are some issues about API and ABI stability guarantees, of course.) One of the qdev intended benefits is to have pretty much self-contained device emulation. If doesn't work equally well everythere. For alot of -- for example -- PCI devices it does work nicely though. Adding a device is simply a matter of dropping a file into the tree and a line into the Makefile and you are done. The device is available to be used via -device. So the cost of maintaining stuff out-of-tree isn't that big as you almost never have patch conflict issues. For embedded stuff it is usually a bit trickier as the device interconnects are hard-coded in the board creation bits and devices can't be hooked up using -device (or some other generic mechanism which uses -- say -- device trees) ... cheers, Gerd
Re: [Qemu-devel] buildbot failure in qemu on xen_x86_64_debian_6_0
On Tue, Nov 1, 2011 at 8:07 AM, Daniel Gollub gol...@b1-systems.de wrote: Hi Stefan, On Tuesday, November 01, 2011 08:36:46 AM Stefan Weil wrote: As far as I know from previous mails, the buildbots already do a retry when git fails. The retry period used today is obviously too short. i finally took a closer look on this failed git reports. It seems like all the git failed mails are not due to a too short reply period. It is due to the buildslave version used on yuzuki is not recent enough to perform retries at all. Other buildslaves which have buildbot version 0.8.2 and greater perform retries correctly and seem to require only one retry to finally succeed. yuzuki is running buildbot version 0.7.12 and doesn't perform any retry and cause nearly all git failed mails since we introduced git-fetch retries. Stefan, could you update your buildslave yuzuki? In meanwhile I try to setup mine buildslave also with a new version of buildbot. Thanks for the pointer. I have upgraded yuzuki to buildbot 0.8.5. Stefan
[Qemu-devel] cpu_x86() ?
hi, the way cpu_exec() is defined is really confused to me. in cpu-exec.c, we define cpu_exec() function. however, each architecture seems to redefine cpu_exec(), like we have in target-i386/cpu.h #define cpu_exec cpu_x86_exec so which cpu_exec() is executed in case of tcg/x86? also, i cannot find the definition of cpu_x86_exec() anywhere. somebody please help? thanks, Jun
Re: [Qemu-devel] buildbot failure in qemu on xen_x86_64_debian_6_0
Hi, i finally took a closer look on this failed git reports. It seems like all the git failed mails are not due to a too short reply period. It is due to the buildslave version used on yuzuki is not recent enough to perform retries at all. Another git issue: Fedora 16 fails because git 1.7.7 errors out on 'git branch -M master'. Guess that needs to be fixed in the GitPoller @ buildmaster? I've also some python bits to send out the log tail with the mails, see below. cheers, Gerd = [ cut here ] def kraxelMessageFormatter(mode, name, build, results, master_status): result = Results[results] defmsg = mail.defaultMessage(mode, name, build, results, master_status); text = list(); text.append(defmsg['body']); # get log for last step logs = build.getLogs() for log in reversed(logs): if log.getName() == 'stdio': break content = log.getText().splitlines() # Note: can be VERY LARGE url = %s/steps/%s/logs/%s % (master_status.getURLForThing(build), log.getStep().getName(), log.getName()) # append log info to standard message text.append(== log tail ==) for line in content[-32:]: text.append(unicode(line,'utf8')) text.append() text.append(== full log ==) text.append(url); return { 'body' : \n.join(text), 'type' : 'plain' } [ ... ] mn = mail.MailNotifier([ other args ] messageFormatter=kraxelMessageFormatter);
Re: [Qemu-devel] [PATCH] block.c typo in comment fixed
On 11/01/2011 08:39 AM, Stefan Hajnoczi wrote: On Tue, Nov 01, 2011 at 01:36:42AM +, matthias@googlemail.com wrote: From: Matthias Bruggermatthias@gmail.com Signed-off-by: Matthias Bruggermatthias@gmail.com --- block.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) Writable is also a common spelling. Try git grep writable and compare against git grep writeable. In qemu.git writable actually dominates by a large majority so we should leave this alone. Stefan Alright, I didn't know that. Sorry for the noise. Regards, Matthias -- --- http://motzblog.wordpress.com/
Re: [Qemu-devel] cpu_x86() ?
the way cpu_exec() is defined is really confused to me. in cpu-exec.c, we define cpu_exec() function. however, each architecture seems to redefine cpu_exec(), like we have in target-i386/cpu.h #define cpu_exec cpu_x86_exec so which cpu_exec() is executed in case of tcg/x86? also, i cannot find the definition of cpu_x86_exec() anywhere. cpu_exec definition in cpu-exec.c takes place after #include cpu.h which contains #define cpu_exec whatever. In case of x86 cpu_x86_exec is actually defined by the cpu-exec.c. -- Thanks. -- Max
Re: [Qemu-devel] [libvirt] RFC decoupling VM NIC provisioning from VM NIC connection to backend networks
On Mon, Oct 31, 2011 at 04:23:35PM -0500, Christian Benvenuti (benve) wrote: -Original Message- From: qemu-devel-bounces+benve=cisco@nongnu.org [mailto:qemu-devel- bounces+benve=cisco@nongnu.org] On Behalf Of Daniel P. Berrange Sent: Monday, October 31, 2011 3:49 AM To: Sumit Naiksatam (snaiksat) Cc: libvir-l...@redhat.com; David Wang (dwang2); Ram Durairaj (radurair); qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [libvirt] RFC decoupling VM NIC provisioning from VM NIC connection to backend networks On Fri, Oct 28, 2011 at 04:15:41PM -0700, Sumit Naiksatam (snaiksat) wrote: Hi, In its current implementation Libvirt makes sure that the network interfaces that it passes/provision to a VM (for example to qemu[- kvm]) are already connected to its backend (interfaces/networks) by the time the VM starts its boot process. In a non virtualized setup it would be like booting a machine with the Ethernet cable already plugged into a router/switch port. While in a non virtualized setup you can boot a machine first (with no physical connection to a router/switch) and later connect its NIC/s to the switch/router, when you boot a VM via Libvirt it is not possible to decouple the two actions (VM boot, cable plug/unplug). An example of case where the capability of decoupling the two actions mentioned above is a requirement in Quantum/NetStack which is the network service leveraged by OpenStack. The modular design of OpenStack allows you to: - provision VMs with NIC/s - create networks - create ports on networks - plug/unplug a VM NIC into/from a given port on a network (at runtime) Note that this runtime plug/unplug requirement has nothing to do with hot plug/unplug of NICs. The idea is more that of decoupling the provisioning of a VM from the connection of the VM to the network/s. This would make it possible to change (at run-time too) the networks the NIC/s of a given VM are connected to. For example, when a VM boots, its interfaces should be in link down state if the network admin has not connected the VM NIC/s to any network yet. Even though libvirt already provides a way to change the link state of an a VM NIC, link state and physical connection are two different things and should be manageable independently. Ideally the configuration syntax should be interface type and hypervisor type agnostic. Let's take QEMU[-kvm] as an example - when Libvirt starts a QEMU VM, it passes to QEMU a number of file descriptors that map to host backend interfaces (for example macvtap interfaces). In order to introduce this runtime plug/unplug capability, we need a mechanism that permits to delay the binding between the host macvtap interfaces and the guest taps (because you cannot know the fd of the macvtap interfaces before you create them). This means you need a mechanism that allows you to change such fd/s at runtime: - you can close/reset an fd (ie, when you disconnect a VM NIC from its network) - you can open/set an fd (ie, when you connect a VM NIC to a network) This could probably be a libvirt command that translates to a QEMU monitor command. Can the runtime plug/unplug capability described above be achieved (cleanly) with another mechanism? Is anybody working on implementing something similar? No, but I've long thought about doing this it is quite straightforward todo really. Ordinarily when we start QEMU we do qemu ... -device e1000,id=nic0,netdev=netdevnic0 \ -netdev user,id=netdevnic0 Todo what you describe we need to be able to: 1. Start QEMU with a NIC, but no netdev 2. Add a netdev to running QEMU. 3. Remove a netdev from a running QEMU 4. Associate a netdev with a NIC in running QEMU We can do 1: $ qemu ... -device e1000,id=nic0 But QEMU prints an annoying warning Warning: nic nic0 has no peer If we introduce this new functionality, can this warning change? If we change it, would it break any test/script? Actually it is just a warning (not an error). Why do you think it is annoying? (I guess it is supposed to catch misconfigurations) We can do 2 via the monitor: (qemu) netdev_add type=user,id=netdevnic0 We can do 3 via the monitor: (qemu) netdev_del netdevnic0 The problem is 4 - AFAICT we can't connect the existing NIC upto the newly hotplugged netdev, since we can't update the 'netdev' property in the NIC device. Also if we delete the netdev, we can't clear out the 'netdev' property in the NIC, so its dangling to a netdev that no longer exists. The latter is fairly harmless, since we can just re-use the name if adding a new backend later. The first problem is a bit of a pain, unless we plug in a 'user' backend on the CLI, and immediately
Re: [Qemu-devel] [PATCH v10 2/3] block: add I/O throttling algorithm
On Tue, Nov 1, 2011 at 7:40 AM, Zhi Yong Wu wu...@linux.vnet.ibm.com wrote: +static void bdrv_io_limits_intercept(BlockDriverState *bs, + int nb_sectors) +{ + int64_t wait_time = -1; + + if (!qemu_co_queue_empty(bs-throttled_reqs)) { + qemu_co_queue_wait(bs-throttled_reqs); + goto resume; + } else if (bdrv_exceed_io_limits(bs, nb_sectors, false, wait_time)) { + if (wait_time != -1) { + qemu_mod_timer(bs-block_timer, + wait_time + qemu_get_clock_ns(vm_clock)); + } + + qemu_co_queue_wait(bs-throttled_reqs); + +resume: + while (bdrv_exceed_io_limits(bs, nb_sectors, false, wait_time)) { is_write needs to be passed in to bdrv_exceed_io_limits(). Currently this accounts every I/O as a read. + qemu_mod_timer(bs-block_timer, + wait_time + qemu_get_clock_ns(vm_clock)); Do you need if (wait_time != -1) here? Stefan
Re: [Qemu-devel] [PATCH v10 2/3] block: add I/O throttling algorithm
On Tue, Nov 1, 2011 at 7:33 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Tue, Nov 1, 2011 at 7:40 AM, Zhi Yong Wu wu...@linux.vnet.ibm.com wrote: +static void bdrv_io_limits_intercept(BlockDriverState *bs, + int nb_sectors) +{ + int64_t wait_time = -1; + + if (!qemu_co_queue_empty(bs-throttled_reqs)) { + qemu_co_queue_wait(bs-throttled_reqs); + goto resume; + } else if (bdrv_exceed_io_limits(bs, nb_sectors, false, wait_time)) { + if (wait_time != -1) { + qemu_mod_timer(bs-block_timer, + wait_time + qemu_get_clock_ns(vm_clock)); + } + + qemu_co_queue_wait(bs-throttled_reqs); + +resume: + while (bdrv_exceed_io_limits(bs, nb_sectors, false, wait_time)) { is_write needs to be passed in to bdrv_exceed_io_limits(). Currently this accounts every I/O as a read. Sorry, It is one stupid error. + qemu_mod_timer(bs-block_timer, + wait_time + qemu_get_clock_ns(vm_clock)); Do you need if (wait_time != -1) here? Actually i think that we can drop the condition in our code. Stefan -- Regards, Zhi Yong Wu
Re: [Qemu-devel] [PATCH] pci: add standard bridge device
On Tue, Nov 01, 2011 at 04:49:08PM +0800, Wen Congyang wrote: At 11/01/2011 04:44 PM, Michael S. Tsirkin Write: On Tue, Nov 01, 2011 at 09:27:25AM +0800, Wen Congyang wrote: Hi, Michael S. Tsirkin At 09/26/2011 03:08 PM, Michael S. Tsirkin Write: On Mon, Sep 26, 2011 at 02:18:15PM +0800, Wen Congyang wrote: Hi, Michael S. Tsirkin At 07/04/2011 05:43 PM, Michael S. Tsirkin Write: This adds support for a standard pci to pci bridge, enabling support for more than 32 PCI devices in the system. To use, specify the device id as a 'bus' option. Example: -device pci-bridge,id=bridge1 \ -netdev user,id=u \ -device ne2k_pci,id=net2,bus=bridge1,netdev=u TODO: device hotplug support. Do you have any plan to implement this? I think this will be needed before merging the bridge code. What will you plan to support? 1. all PCI-to-PCI bridge is not hotpluggable. host bridge | - | | bridgebridge = *not* hotpluggable | | --- | | || slot slot slot slot = hotplug here 2. PCI-to-PCI bridge is hotpluggable. bridge | --- | | bridge on slot bridge on slot = hot-plug here | | --- --- | | | | slot slot slot slot= hot-plug here It seems easier to start with a non hotpluggable bridge. I'm still trying to understand how is bridge hotplug supposed to work under ACPI, which wants all devices described in a static page. I read the qemu's code, and find that qemu uses PIIX4_PM to support pci device hot plugging on PCI bus 0. How to support it on the other bus? Add PIIX4_PM to each PCI bus or implement a new power management? Thanks Wen Congyang There are many valid options. One is shpc interface. I started looking into this but got preempted by other tasks. Hope to get back to this at some point. Some old OS does not support shpc. So I think it's better to use ACPI to do it. Yes, but ACPI can drive SHPC. Currently, we get which device is removed or inserted by reading the I/O port 0xae00(length: 8 bytes), and _EJ0 method uses I/O port 0xae08(length: 4 bytes). How do we determine this I/O address? Is there any spec to describe it? I don't think so. Thanks Wen Congyang Can we discuss these questions on the mailing list? No problem. I have cced qemu mailing list. Thanks Wen Congyang
[Qemu-devel] [PATCH v10 2/3] block: add I/O throttling algorithm
Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com --- block.c | 230 + block.h |1 + block_int.h |1 + qemu-coroutine-lock.c |8 ++ qemu-coroutine.h |6 ++ 5 files changed, 246 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 8f08dc5..08b6ec6 100644 --- a/block.c +++ b/block.c @@ -74,6 +74,13 @@ static BlockDriverAIOCB *bdrv_co_aio_rw_vector(BlockDriverState *bs, bool is_write); static void coroutine_fn bdrv_co_do_rw(void *opaque); +static bool bdrv_exceed_bps_limits(BlockDriverState *bs, int nb_sectors, +bool is_write, double elapsed_time, uint64_t *wait); +static bool bdrv_exceed_iops_limits(BlockDriverState *bs, bool is_write, +double elapsed_time, uint64_t *wait); +static bool bdrv_exceed_io_limits(BlockDriverState *bs, int nb_sectors, +bool is_write, int64_t *wait); + static QTAILQ_HEAD(, BlockDriverState) bdrv_states = QTAILQ_HEAD_INITIALIZER(bdrv_states); @@ -107,6 +114,28 @@ int is_windows_drive(const char *filename) #endif /* throttling disk I/O limits */ +void bdrv_io_limits_disable(BlockDriverState *bs) +{ +bs-io_limits_enabled = false; + +if (!qemu_co_queue_empty(bs-throttled_reqs)) { +while (qemu_co_queue_next(bs-throttled_reqs)); +} + +qemu_co_queue_init(bs-throttled_reqs); + +if (bs-block_timer) { +qemu_del_timer(bs-block_timer); +qemu_free_timer(bs-block_timer); +bs-block_timer = NULL; +} + +bs-slice_start = 0; +bs-slice_end = 0; +bs-slice_time = 0; +memset(bs-io_disps, 0, sizeof(bs-io_disps)); +} + static void bdrv_block_timer(void *opaque) { BlockDriverState *bs = opaque; @@ -137,6 +166,35 @@ bool bdrv_io_limits_enabled(BlockDriverState *bs) || io_limits-iops[BLOCK_IO_LIMIT_TOTAL]; } +static void bdrv_io_limits_intercept(BlockDriverState *bs, + bool is_write, int nb_sectors) +{ +int64_t wait_time = -1; + +if (!qemu_co_queue_empty(bs-throttled_reqs)) { +qemu_co_queue_wait(bs-throttled_reqs); +goto resume; +} else if (bdrv_exceed_io_limits(bs, nb_sectors, is_write, wait_time)) { +if (wait_time != -1) { +qemu_mod_timer(bs-block_timer, + wait_time + qemu_get_clock_ns(vm_clock)); +} + +qemu_co_queue_wait(bs-throttled_reqs); + +resume: +while (bdrv_exceed_io_limits(bs, nb_sectors, is_write, wait_time)) { +if (wait_time != -1) { +qemu_mod_timer(bs-block_timer, + wait_time + qemu_get_clock_ns(vm_clock)); +} +qemu_co_queue_wait_insert_head(bs-throttled_reqs); +} + +qemu_co_queue_next(bs-throttled_reqs); +} +} + /* check if the path starts with protocol: */ static int path_has_protocol(const char *path) { @@ -719,6 +777,11 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags, bdrv_dev_change_media_cb(bs, true); } +/* throttling disk I/O limits */ +if (bs-io_limits_enabled) { +bdrv_io_limits_enable(bs); +} + return 0; unlink_and_fail: @@ -754,6 +817,9 @@ void bdrv_close(BlockDriverState *bs) bdrv_dev_change_media_cb(bs, false); } + +/*throttling disk I/O limits*/ +bdrv_io_limits_disable(bs); } void bdrv_close_all(void) @@ -1292,6 +1358,11 @@ static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs, return -EIO; } +/* throttling disk read I/O */ +if (bs-io_limits_enabled) { +bdrv_io_limits_intercept(bs, false, nb_sectors); +} + return drv-bdrv_co_readv(bs, sector_num, nb_sectors, qiov); } @@ -1322,6 +1393,11 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs, return -EIO; } +/* throttling disk write I/O */ +if (bs-io_limits_enabled) { +bdrv_io_limits_intercept(bs, true, nb_sectors); +} + ret = drv-bdrv_co_writev(bs, sector_num, nb_sectors, qiov); if (bs-dirty_bitmap) { @@ -2513,6 +2589,160 @@ void bdrv_aio_cancel(BlockDriverAIOCB *acb) acb-pool-cancel(acb); } +/* block I/O throttling */ +static bool bdrv_exceed_bps_limits(BlockDriverState *bs, int nb_sectors, + bool is_write, double elapsed_time, uint64_t *wait) { +uint64_t bps_limit = 0; +double bytes_limit, bytes_disp, bytes_res; +double slice_time, wait_time; + +if (bs-io_limits.bps[BLOCK_IO_LIMIT_TOTAL]) { +bps_limit = bs-io_limits.bps[BLOCK_IO_LIMIT_TOTAL]; +} else if (bs-io_limits.bps[is_write]) { +bps_limit = bs-io_limits.bps[is_write]; +} else { +if (wait) { +*wait = 0; +} + +return false; +} + +slice_time = bs-slice_end - bs-slice_start; +slice_time /= (NANOSECONDS_PER_SECOND); +
[Qemu-devel] [PULL] spice patch queue
Hi, Carrying three little qxl fixes. Final spice batch for 1.0. please pull, Gerd The following changes since commit ff74c5a9a91c6dbf1017195462aa4176f7381240: Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging (2011-10-31 15:05:40 -0500) are available in the git repository at: git://anongit.freedesktop.org/spice/qemu spice.v46 Alon Levy (1): qxl: create slots on post_load in vga state Gerd Hoffmann (2): qxl: stride fixup qxl: make sure we continue to run with a shared buffer hw/qxl-render.c | 36 hw/qxl.c| 26 +++--- hw/qxl.h|3 ++- 3 files changed, 45 insertions(+), 20 deletions(-)
[Qemu-devel] [PATCH 3/3] qxl: create slots on post_load in vga state
From: Alon Levy al...@redhat.com RHBZ 740547 If we migrate when the device is in vga state the guest still believes the slots are created, and will cause operations that reference the slots, causing a panic: virtual address out of range on the first of them. Easy to see by migrating in vga mode with a driver loaded, for instance windows cmd window in full screen mode, and then exiting vga mode back to native mode will cause said panic. Fixed by doing the slot recreation in post_load for vga mode as well. Note that compat does not require any changes because it creates it's only slot by a side effect of QXL_IO_SET_MODE. Signed-off-by: Alon Levy al...@redhat.com Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/qxl.c | 26 +++--- 1 files changed, 19 insertions(+), 7 deletions(-) diff --git a/hw/qxl.c b/hw/qxl.c index 12f71aa..84ffd45 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -1663,12 +1663,25 @@ static int qxl_pre_load(void *opaque) return 0; } +static void qxl_create_memslots(PCIQXLDevice *d) +{ +int i; + +for (i = 0; i NUM_MEMSLOTS; i++) { +if (!d-guest_slots[i].active) { +continue; +} +dprint(d, 1, %s: restoring guest slot %d\n, __func__, i); +qxl_add_memslot(d, i, 0, QXL_SYNC); +} +} + static int qxl_post_load(void *opaque, int version) { PCIQXLDevice* d = opaque; uint8_t *ram_start = d-vga.vram_ptr; QXLCommandExt *cmds; -int in, out, i, newmode; +int in, out, newmode; dprint(d, 1, %s: start\n, __FUNCTION__); @@ -1685,19 +1698,16 @@ static int qxl_post_load(void *opaque, int version) qxl_mode_to_string(d-mode)); newmode = d-mode; d-mode = QXL_MODE_UNDEFINED; + switch (newmode) { case QXL_MODE_UNDEFINED: break; case QXL_MODE_VGA: +qxl_create_memslots(d); qxl_enter_vga_mode(d); break; case QXL_MODE_NATIVE: -for (i = 0; i NUM_MEMSLOTS; i++) { -if (!d-guest_slots[i].active) { -continue; -} -qxl_add_memslot(d, i, 0, QXL_SYNC); -} +qxl_create_memslots(d); qxl_create_guest_primary(d, 1, QXL_SYNC); /* replay surface-create and cursor-set commands */ @@ -1722,6 +1732,8 @@ static int qxl_post_load(void *opaque, int version) break; case QXL_MODE_COMPAT: +/* note: no need to call qxl_create_memslots, qxl_set_mode + * creates the mem slot. */ qxl_set_mode(d, d-shadow_rom.mode, 1); break; } -- 1.7.1
[Qemu-devel] [PATCH 2/3] qxl: make sure we continue to run with a shared buffer
The qxl renderer works only with a shared displaysurface. So better make sure we actually have one and restore it when needed. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/qxl-render.c | 13 - 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/hw/qxl-render.c b/hw/qxl-render.c index a567693..2c51ba9 100644 --- a/hw/qxl-render.c +++ b/hw/qxl-render.c @@ -76,7 +76,14 @@ void qxl_render_update(PCIQXLDevice *qxl) VGACommonState *vga = qxl-vga; QXLRect dirty[32], update; void *ptr; -int i; +int i, redraw = 0; + +if (!is_buffer_shared(vga-ds-surface)) { +dprint(qxl, 1, %s: restoring shared displaysurface\n, __func__); +qxl-guest_primary.resized++; +qxl-guest_primary.commands++; +redraw = 1; +} if (qxl-guest_primary.resized) { qxl-guest_primary.resized = 0; @@ -127,6 +134,10 @@ void qxl_render_update(PCIQXLDevice *qxl) memset(dirty, 0, sizeof(dirty)); qxl_spice_update_area(qxl, 0, update, dirty, ARRAY_SIZE(dirty), 1, QXL_SYNC); +if (redraw) { +memset(dirty, 0, sizeof(dirty)); +dirty[0] = update; +} for (i = 0; i ARRAY_SIZE(dirty); i++) { if (qemu_spice_rect_is_empty(dirty+i)) { -- 1.7.1
[Qemu-devel] [PATCH 1/3] qxl: stride fixup
spice uses negative stride value to signal the bitmap is upside down. The qxl renderer (used for scl, vnc and screenshots) wants a positive value because it is easier to work with. The positive value is then stored in the very same variable, which has the drawback that the upside-down test works only once. Fix by using two variables. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/qxl-render.c | 23 --- hw/qxl.h|3 ++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/hw/qxl-render.c b/hw/qxl-render.c index c290739..a567693 100644 --- a/hw/qxl-render.c +++ b/hw/qxl-render.c @@ -28,16 +28,16 @@ static void qxl_flip(PCIQXLDevice *qxl, QXLRect *rect) int len, i; src += (qxl-guest_primary.surface.height - rect-top - 1) * -qxl-guest_primary.stride; -dst += rect-top * qxl-guest_primary.stride; +qxl-guest_primary.abs_stride; +dst += rect-top * qxl-guest_primary.abs_stride; src += rect-left * qxl-guest_primary.bytes_pp; dst += rect-left * qxl-guest_primary.bytes_pp; len = (rect-right - rect-left) * qxl-guest_primary.bytes_pp; for (i = rect-top; i rect-bottom; i++) { memcpy(dst, src, len); -dst += qxl-guest_primary.stride; -src -= qxl-guest_primary.stride; +dst += qxl-guest_primary.abs_stride; +src -= qxl-guest_primary.abs_stride; } } @@ -45,7 +45,8 @@ void qxl_render_resize(PCIQXLDevice *qxl) { QXLSurfaceCreate *sc = qxl-guest_primary.surface; -qxl-guest_primary.stride = sc-stride; +qxl-guest_primary.qxl_stride = sc-stride; +qxl-guest_primary.abs_stride = abs(sc-stride); qxl-guest_primary.resized++; switch (sc-format) { case SPICE_SURFACE_FMT_16_555: @@ -87,11 +88,11 @@ void qxl_render_update(PCIQXLDevice *qxl) qemu_free_displaysurface(vga-ds); qxl-guest_primary.data = memory_region_get_ram_ptr(qxl-vga.vram); -if (qxl-guest_primary.stride 0) { +if (qxl-guest_primary.qxl_stride 0) { /* spice surface is upside down - need extra buffer to flip */ -qxl-guest_primary.stride = -qxl-guest_primary.stride; -qxl-guest_primary.flipped = g_malloc(qxl-guest_primary.surface.width * - qxl-guest_primary.stride); +qxl-guest_primary.flipped = +g_malloc(qxl-guest_primary.surface.width * + qxl-guest_primary.abs_stride); ptr = qxl-guest_primary.flipped; } else { ptr = qxl-guest_primary.data; @@ -100,7 +101,7 @@ void qxl_render_update(PCIQXLDevice *qxl) __FUNCTION__, qxl-guest_primary.surface.width, qxl-guest_primary.surface.height, - qxl-guest_primary.stride, + qxl-guest_primary.qxl_stride, qxl-guest_primary.bytes_pp, qxl-guest_primary.bits_pp, qxl-guest_primary.flipped ? yes : no); @@ -108,7 +109,7 @@ void qxl_render_update(PCIQXLDevice *qxl) qemu_create_displaysurface_from(qxl-guest_primary.surface.width, qxl-guest_primary.surface.height, qxl-guest_primary.bits_pp, -qxl-guest_primary.stride, +qxl-guest_primary.abs_stride, ptr); dpy_resize(vga-ds); } diff --git a/hw/qxl.h b/hw/qxl.h index 37b2619..766aa6d 100644 --- a/hw/qxl.h +++ b/hw/qxl.h @@ -48,7 +48,8 @@ typedef struct PCIQXLDevice { QXLSurfaceCreate surface; uint32_t commands; uint32_t resized; -int32_tstride; +int32_tqxl_stride; +uint32_t abs_stride; uint32_t bits_pp; uint32_t bytes_pp; uint8_t*data, *flipped; -- 1.7.1
Re: [Qemu-devel] [PULL 0/3] 128-bit support for the memory API
On 11/01/2011 03:43 AM, Avi Kivity wrote: On 11/01/2011 02:54 AM, David Gibson wrote: On Mon, Oct 31, 2011 at 11:05:47AM -0500, Anthony Liguori wrote: On 10/30/2011 09:02 AM, Avi Kivity wrote: This somewhat controversial patchset converts internal arithmetic in the memory API to 128 bits. Given the level of controversy, what do you think about deferring this to 1.1? If it's deferred then one of my rearrangements for the arithmetic must go in instead. These patches fix real bugs, that bite us on pseries. It's not the only way to fix those bugs, and probably not even my personally preferred way to fix them, but they need to be fixed _somehow_ for 1.0. Yes, plus if one of them is exploitable, then it's certainly a must for 1.0. Since it's just internal, I'll just pull this series and if we want to change it post 1.0, we can. Regards, Anthony Liguori
Re: [Qemu-devel] [PATCH] Simplify cpu_exec_all to tcg_exec_all
On 2011-11-01 11:00, Jun Koi wrote: i have sent a patch, which duplicated the function of this patch. this one was not approved yet?? I assume my patch is in some queue, just waiting to be reviewed and applied. Jan signature.asc Description: OpenPGP digital signature
Re: [Qemu-devel] Performance of USB2.0
Hi. Am 01.11.2011 10:37, schrieb Gerd Hoffmann: I think the main issue here is that we don't do buffering / pipelining for bulk transfers at the moment. We grab a single transfer request from the guest, pass it to the kernel, when it is done pass it back to the guest, then look look for the next one. Instead we could queue up all transfer requests from the guest to the kernel, which would give a noticable better throughput. The qemu usb subsystem can't handle that (yet). Fixing that is one the TODO list though. Additionally all bulk xfer processing is done in the 1000 Hz frame timer, which combined with the above limits the number of packets to 1000 packets per second (and direction), i.e. with a MTU of 1500 you'll get 1500 * 1000 = 1.5 MB/s max. This you can expect to get with the current code. Add some protocol and other overhead to the 7 MBit/s you are actually seeing and the numbers are pretty close, so there isn't much room to improve things. The only option I see is to operate the device with an larger MTU if the usb device and your network setup can handle that. That helps and explains why there is no speed difference between 1.1 and 2.0 at my tests. How can i help to prioritize this issue? ;) Regards Til
Re: [Qemu-devel] [PATCH 1/2] Allow 1366x768 as a valid VGA resolution
I don't know of any reason for it. -John On Nov 1, 2011, at 4:58 AM, Gerd Hoffmann kra...@redhat.com wrote: On 10/28/11 21:24, John Baboval wrote: 760p TV panels have a 1366x768 resolution, and have been popular recently as low-cost monitors. The 1366 resolution doesn't pass the (xres 7) == 0 test. Why is it save to simply remove the test? Guess there is a reason why it is there in the first place? cheers, Gerd
Re: [Qemu-devel] KVM call agenda for November 1st
On Mon, Oct 31, 2011 at 08:09:31PM +0100, Juan Quintela wrote: Hi Please send in any agenda items you are interested in covering. Thanks, Juan. PD. Tomorrow is a Spanish holiday, so I would not attend the call. As there are no agenda items, todays call is cancelled. Justin
Re: [Qemu-devel] [PATCH V2] Introduce a new bus ICC to connect APIC
On 2011-11-01 08:41, pingf...@linux.vnet.ibm.com wrote: From: Liu Ping Fan pingf...@linux.vnet.ibm.com Introduce a new structure CPUS as the controller of ICC (INTERRUPT CONTROLLER COMMUNICATIONS), and new bus ICC to hold APIC,instead of sysbus. So we can support APIC hot-plug feature. Signed-off-by: liu ping fan pingf...@linux.vnet.ibm.com --- Makefile.target |1 + hw/apic.c | 24 + hw/apic.h |1 + hw/icc_bus.c| 92 +++ hw/icc_bus.h| 61 + hw/pc.c |9 +++-- hw/pc_piix.c| 14 +++- target-i386/cpu.h |1 + target-i386/cpuid.c | 16 + 9 files changed, 207 insertions(+), 12 deletions(-) create mode 100644 hw/icc_bus.c create mode 100644 hw/icc_bus.h diff --git a/Makefile.target b/Makefile.target index 9011f28..5607c6d 100644 --- a/Makefile.target +++ b/Makefile.target @@ -241,6 +241,7 @@ obj-i386-$(CONFIG_KVM) += kvmclock.o obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o obj-i386-y += testdev.o obj-i386-y += acpi.o acpi_piix4.o +obj-i386-y += icc_bus.o obj-i386-y += pcspk.o i8254.o obj-i386-$(CONFIG_KVM_PIT) += i8254-kvm.o diff --git a/hw/apic.c b/hw/apic.c index 69d6ac5..34fa1dd 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -21,9 +21,10 @@ #include ioapic.h #include qemu-timer.h #include host-utils.h -#include sysbus.h +#include icc_bus.h #include trace.h #include kvm.h +#include exec-memory.h /* APIC Local Vector Table */ #define APIC_LVT_TIMER 0 @@ -80,7 +81,7 @@ typedef struct APICState APICState; struct APICState { -SysBusDevice busdev; +ICCBusDevice busdev; MemoryRegion io_memory; void *cpu_env; uint32_t apicbase; @@ -1104,9 +1105,19 @@ static const MemoryRegionOps apic_io_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -static int apic_init1(SysBusDevice *dev) +int apic_mmio_map(DeviceState *dev, target_phys_addr_t base) { -APICState *s = FROM_SYSBUS(APICState, dev); +APICState *s = DO_UPCAST(APICState, busdev.qdev, dev); + +memory_region_add_subregion(get_system_memory(), +base, +s-io_memory); +return 0; +} + +static int apic_init1(ICCBusDevice *dev) +{ +APICState *s = DO_UPCAST(APICState, busdev, dev); static int last_apic_idx; if (last_apic_idx = MAX_APICS) { @@ -1114,7 +1125,6 @@ static int apic_init1(SysBusDevice *dev) } memory_region_init_io(s-io_memory, apic_io_ops, s, apic, MSI_ADDR_SIZE); -sysbus_init_mmio_region(dev, s-io_memory); s-timer = qemu_new_timer_ns(vm_clock, apic_timer, s); s-idx = last_apic_idx++; @@ -1122,7 +1132,7 @@ static int apic_init1(SysBusDevice *dev) return 0; } -static SysBusDeviceInfo apic_info = { +static ICCBusDeviceInfo apic_info = { .init = apic_init1, .qdev.name = apic, .qdev.size = sizeof(APICState), @@ -1138,7 +1148,7 @@ static SysBusDeviceInfo apic_info = { static void apic_register_devices(void) { -sysbus_register_withprop(apic_info); +iccbus_register_devinfo(apic_info); } device_init(apic_register_devices) diff --git a/hw/apic.h b/hw/apic.h index c857d52..e2c0af5 100644 --- a/hw/apic.h +++ b/hw/apic.h @@ -20,6 +20,7 @@ void cpu_set_apic_tpr(DeviceState *s, uint8_t val); uint8_t cpu_get_apic_tpr(DeviceState *s); void apic_init_reset(DeviceState *s); void apic_sipi(DeviceState *s); +int apic_mmio_map(DeviceState *dev, target_phys_addr_t base); /* pc.c */ int cpu_is_bsp(CPUState *env); diff --git a/hw/icc_bus.c b/hw/icc_bus.c new file mode 100644 index 000..ac88f2e --- /dev/null +++ b/hw/icc_bus.c @@ -0,0 +1,92 @@ +/* icc_bus.c + * emulate x86 ICC(INTERRUPT CONTROLLER COMMUNICATIONS) bus + * + * Copyright IBM, Corp. 2011 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see http://www.gnu.org/licenses/ + */ +#include icc_bus.h + +static CPUSockets *cpu_sockets; + +static ICCBusInfo icc_bus_info = { +.qinfo.name = icc, +.qinfo.size = sizeof(ICCBus), +.qinfo.props = (Property[]) { +DEFINE_PROP_END_OF_LIST(), +} +}; + +static int
Re: [Qemu-devel] [PULL 0/3] 128-bit support for the memory API
Am 01.11.2011 13:59, schrieb Anthony Liguori: On 11/01/2011 03:43 AM, Avi Kivity wrote: On 11/01/2011 02:54 AM, David Gibson wrote: On Mon, Oct 31, 2011 at 11:05:47AM -0500, Anthony Liguori wrote: On 10/30/2011 09:02 AM, Avi Kivity wrote: This somewhat controversial patchset converts internal arithmetic in the memory API to 128 bits. Given the level of controversy, what do you think about deferring this to 1.1? If it's deferred then one of my rearrangements for the arithmetic must go in instead. These patches fix real bugs, that bite us on pseries. It's not the only way to fix those bugs, and probably not even my personally preferred way to fix them, but they need to be fixed _somehow_ for 1.0. Yes, plus if one of them is exploitable, then it's certainly a must for 1.0. Since it's just internal, I'll just pull this series and if we want to change it post 1.0, we can. FWIW I must say I don't like where this is heading... iiuc just because of a zero-or-full-64-bits issue with start+end we're doubling the internal storage format for all memory ranges. If having the size unsigned would eliminate the overflow issue at hand, can't we move the signedness to some flag field instead? I don't see a problem with using macros/inlines, just with the seemingly unnecessary 128-bitness. In particular I'm thinking of ARM. Since this seems to be addressing an overflow bug in ppc64, the hard-freeze date shouldn't make us rush this IMO. Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v3 1/4] Add basic version of bridge helper
On 11/01/2011 04:15 AM, Stefan Hajnoczi wrote: On Mon, Oct 31, 2011 at 02:36:28PM -0400, Corey Bryant wrote: A couple of nitpicks regarding error handling: +static int has_vnet_hdr(int fd) +{ +unsigned int features = 0; +struct ifreq ifreq; + +if (ioctl(fd, TUNGETFEATURES,features) == -1) { +return -errno; +} + +if (!(features IFF_VNET_HDR)) { +return -ENOTSUP; +} + +if (ioctl(fd, TUNGETIFF,ifreq) != -1 || errno != EBADFD) { +return -ENOTSUP; +} + +return 1; +} This function is strange, it looks like a boolean function but actually only returns 1 or -errno. It is used incorrectly in main(). I suggest changing the return value to bool and returning false on error. Ah, good catch, this was a bug. And I agree that bool would work better. I'll fix this. +/* open a socket to use to control the network interfaces */ +ctlfd = socket(AF_INET, SOCK_STREAM, 0); +if (ctlfd == -1) { +fprintf(stderr, failed to open control socket\n); +ret = -errno; It's better to stash away errno before invoking other library functions. man errno(3) says: a function that succeeds is allowed to change errno This means fprintf(3) could clobber errno. I suggest simply printing out errno with the error message and returning exit code 1 (EXIT_FAILURE). The same applies for the other error exit cases in main(). I agree. I'll fix this. +cleanup: + +close(fd); + +close(ctlfd); ctlfd is an uninitialized variable if opening fd fails. We also never close unixfd. I'd remove this cleanup code and just return without closing any file descriptors - let the kernel do it. Ok, I'll do this. But I think I'll re-introduce the cleanup goto in patch 2/4 to free the simple queue memory. -- Regards, Corey Stefan
[Qemu-devel] [PULL 0/1] Tracing patches
The last tracing tree patch for QEMU 1.0! The following changes since commit ff74c5a9a91c6dbf1017195462aa4176f7381240: Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging (2011-10-31 15:05:40 -0500) are available in the git repository at: ssh://repo.or.cz/srv/git/qemu/stefanha.git tracing Mark Wu (1): trace: Add wildcard trace event support docs/tracing.txt |9 - trace/simple.c | 17 - trace/stderr.c | 17 - 3 files changed, 40 insertions(+), 3 deletions(-) -- 1.7.7
[Qemu-devel] [PATCH 1/1] trace: Add wildcard trace event support
From: Mark Wu wu...@linux.vnet.ibm.com A basic wildcard matching is supported in both the monitor command trace-event and the events list file. That means you can enable/disable the events having a common prefix in a batch. For example, virtio-blk trace events could be enabled using: trace-event virtio_blk_* on Signed-off-by: Mark Wu wu...@linux.vnet.ibm.com Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com --- docs/tracing.txt |9 - trace/simple.c | 17 - trace/stderr.c | 17 - 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/docs/tracing.txt b/docs/tracing.txt index 95ca16c..ea29f2c 100644 --- a/docs/tracing.txt +++ b/docs/tracing.txt @@ -132,12 +132,19 @@ This functionality is also provided through monitor commands: means disabled. * trace-event NAME on|off - Enable/disable a given trace event. + Enable/disable a given trace event or a group of events having common prefix + through wildcard. The -trace events=file command line argument can be used to enable the events listed in file from the very beginning of the program. This file must contain one event name per line. +A basic wildcard matching is supported in both the monitor command trace +-event and the events list file. That means you can enable/disable the events +having a common prefix in a batch. For example, virtio-blk trace events could +be enabled using: + trace-event virtio_blk_* on + == Trace backends == The tracetool script automates tedious trace event code generation and also diff --git a/trace/simple.c b/trace/simple.c index b639dda..6339152 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -324,14 +324,29 @@ void trace_print_events(FILE *stream, fprintf_function stream_printf) bool trace_event_set_state(const char *name, bool state) { unsigned int i; +unsigned int len; +bool wildcard = false; +bool matched = false; +len = strlen(name); +if (len 0 name[len - 1] == '*') { +wildcard = true; +len -= 1; +} for (i = 0; i NR_TRACE_EVENTS; i++) { +if (wildcard) { +if (!strncmp(trace_list[i].tp_name, name, len)) { +trace_list[i].state = state; +matched = true; +} +continue; +} if (!strcmp(trace_list[i].tp_name, name)) { trace_list[i].state = state; return true; } } -return false; +return matched; } /* Helper function to create a thread with signals blocked. Use glib's diff --git a/trace/stderr.c b/trace/stderr.c index 7107c4a..0810d6f 100644 --- a/trace/stderr.c +++ b/trace/stderr.c @@ -15,14 +15,29 @@ void trace_print_events(FILE *stream, fprintf_function stream_printf) bool trace_event_set_state(const char *name, bool state) { unsigned int i; +unsigned int len; +bool wildcard = false; +bool matched = false; +len = strlen(name); +if (len 0 name[len - 1] == '*') { +wildcard = true; +len -= 1; +} for (i = 0; i NR_TRACE_EVENTS; i++) { +if (wildcard) { +if (!strncmp(trace_list[i].tp_name, name, len)) { +trace_list[i].state = state; +matched = true; +} +continue; +} if (!strcmp(trace_list[i].tp_name, name)) { trace_list[i].state = state; return true; } } -return false; +return matched; } bool trace_backend_init(const char *events, const char *file) -- 1.7.7
[Qemu-devel] State of KVM guest debugging support on Power
Hi there, I'm generating some slides on guest debugging via kvm. What's the current state for Book-E and Book-S? Works out of box, mostly usable, or to be implemented? Is anyone using it? Thanks, Jan signature.asc Description: OpenPGP digital signature
Re: [Qemu-devel] [RFC 0/6] block: generic copy-on-read
Hi Marcelo, Thanks for your comments on the copy-on-read RFC patches. I am going to send a rebased series out for review/merge. Did you have any other thoughts - I hope I've addressed your questions? Stefan
Re: [Qemu-devel] GSoC mentor summit QEMU users session
Am 29.10.2011 15:52, schrieb Alexander Graf: We should also show people unmaintained areas. The conclusion was a wiki page with subsystems and status so people know what to expect. We already have: http://wiki.qemu.org/Features And in some places it used to defer from MAINTAINERS. Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] cpu_x86() ?
On Tue, Nov 1, 2011 at 6:58 PM, Max Filippov jcmvb...@gmail.com wrote: the way cpu_exec() is defined is really confused to me. in cpu-exec.c, we define cpu_exec() function. however, each architecture seems to redefine cpu_exec(), like we have in target-i386/cpu.h #define cpu_exec cpu_x86_exec so which cpu_exec() is executed in case of tcg/x86? also, i cannot find the definition of cpu_x86_exec() anywhere. cpu_exec definition in cpu-exec.c takes place after #include cpu.h which contains #define cpu_exec whatever. In case of x86 cpu_x86_exec is actually defined by the cpu-exec.c. ok, so which means cpu_exec is redefined accordingly to each architecture. why do we need to do this weird thing? as there is no namespace collision it seems between architectures, why dont we just let cpu_exec() be cpu_exec()? is this a trick? i cannot figure out why. thanks, Jun
Re: [Qemu-devel] [PATCH] hw/9pfs: use g_vasprintf() instead of rolling our own
On Tue, 1 Nov 2011 07:50:51 +, Stefan Hajnoczi stefa...@linux.vnet.ibm.com wrote: On Mon, Oct 31, 2011 at 11:28:45PM +0530, Aneesh Kumar K.V wrote: On Mon, 31 Oct 2011 11:49:33 +, Stefan Hajnoczi stefa...@linux.vnet.ibm.com wrote: Markus Armbruster arm...@redhat.com sent fixes for va_list vararg issues in v9fs_string_alloc_printf(). It turns out the function duplicates g_vasprintf() and can therefore be eliminated entirely. Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com Reviewed-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Do you want to take this into your 9pfs tree? Will push this through v9fs.git Thanks -aneesh
Re: [Qemu-devel] cpu_x86() ?
Am 01.11.2011 15:34, schrieb Jun Koi: On Tue, Nov 1, 2011 at 6:58 PM, Max Filippov jcmvb...@gmail.com wrote: the way cpu_exec() is defined is really confused to me. in cpu-exec.c, we define cpu_exec() function. however, each architecture seems to redefine cpu_exec(), like we have in target-i386/cpu.h #define cpu_exec cpu_x86_exec so which cpu_exec() is executed in case of tcg/x86? also, i cannot find the definition of cpu_x86_exec() anywhere. cpu_exec definition in cpu-exec.c takes place after #include cpu.h which contains #define cpu_exec whatever. In case of x86 cpu_x86_exec is actually defined by the cpu-exec.c. ok, so which means cpu_exec is redefined accordingly to each architecture. why do we need to do this weird thing? as there is no namespace collision it seems between architectures, why dont we just let cpu_exec() be cpu_exec()? See the recent discussion about heterogeneous system emulation. Such redefinitions are a handy way to avoid name collisions across architectures. Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] cpu_x86() ?
cpu_exec definition in cpu-exec.c takes place after #include cpu.h which contains #define cpu_exec whatever. In case of x86 cpu_x86_exec is actually defined by the cpu-exec.c. ok, so which means cpu_exec is redefined accordingly to each architecture. why do we need to do this weird thing? as there is no namespace collision it seems between architectures, why dont we just let cpu_exec() be cpu_exec()? is this a trick? i cannot figure out why. One theory about it is the following (quoted from http://lists.nongnu.org/archive/html/qemu-devel/2011-05/msg02921.html): One of the long standing goals for QEMU has been to be able to use a single executable to emulate multiple architectures. I think for example the lines like #define cpu_init cpu_sparc_init #define cpu_exec cpu_sparc_exec etc. stand for this purpose, so there has been some consideration for this. Thanks. -- Max
Re: [Qemu-devel] GSoC mentor summit QEMU users session
On 11/01/2011 09:28 AM, Andreas Färber wrote: Am 29.10.2011 15:52, schrieb Alexander Graf: We should also show people unmaintained areas. The conclusion was a wiki page with subsystems and status so people know what to expect. We already have: http://wiki.qemu.org/Features And in some places it used to defer from MAINTAINERS. I think it's better to use MAINTAINERS to coordinate this information. If someone can take a pass at checking it for accuracy and adding some unmaintained subsystems, I'm sure that would go a long ways. Regards, Anthony Liguori Andreas
[Qemu-devel] [PULL] usb patch queue
Hi, Three little usb patches for 1.0. please pull, Gerd The following changes since commit ff74c5a9a91c6dbf1017195462aa4176f7381240: Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging (2011-10-31 15:05:40 -0500) are available in the git repository at: git://git.kraxel.org/qemu usb.29 Gerd Hoffmann (2): usb-hub: wakeup on attach usb-host: fix host close Roy Tam (1): usb: change VID/PID for usb-hub and usb-msd to prevent conflict hw/usb-hub.c |5 +++-- hw/usb-msd.c |4 ++-- usb-linux.c |6 -- 3 files changed, 9 insertions(+), 6 deletions(-)
[Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach
When attaching a new device we must send a wakeup request to the root hub, otherwise the guest will not notice the new device in case the usb hub is suspended. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb-hub.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/hw/usb-hub.c b/hw/usb-hub.c index 09c6516..7b47079 100644 --- a/hw/usb-hub.c +++ b/hw/usb-hub.c @@ -163,6 +163,7 @@ static void usb_hub_attach(USBPort *port1) } else { port-wPortStatus = ~PORT_STAT_LOW_SPEED; } +usb_wakeup(s-dev); } static void usb_hub_detach(USBPort *port1) -- 1.7.1
[Qemu-devel] [PATCH 2/3] usb: change VID/PID for usb-hub and usb-msd to prevent conflict
From: Roy Tam roy...@gmail.com Some USB drivers, for example USBASPI.SYS, will skip different type of device which has same VID/PID. The following patch helps preventing usb-msd being skipped by the driver. Sign-off-by: Roy Tam roy...@gmail.com Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb-hub.c |4 ++-- hw/usb-msd.c |4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/usb-hub.c b/hw/usb-hub.c index 7b47079..3eb0f1a 100644 --- a/hw/usb-hub.c +++ b/hw/usb-hub.c @@ -127,8 +127,8 @@ static const USBDescDevice desc_device_hub = { static const USBDesc desc_hub = { .id = { -.idVendor = 0, -.idProduct = 0, +.idVendor = 0x0409, +.idProduct = 0x55aa, .bcdDevice = 0x0101, .iManufacturer = STR_MANUFACTURER, .iProduct = STR_PRODUCT, diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 1a0815a..b734177 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -162,8 +162,8 @@ static const USBDescDevice desc_device_high = { static const USBDesc desc = { .id = { -.idVendor = 0, -.idProduct = 0, +.idVendor = 0x46f4, /* CRC16() of QEMU */ +.idProduct = 0x0001, .bcdDevice = 0, .iManufacturer = STR_MANUFACTURER, .iProduct = STR_PRODUCT, -- 1.7.1
[Qemu-devel] [PATCH 3/3] usb-host: fix host close
The whole usb_host_close() function is skipped in case the device is not in attached state. This is wrong though, only then usb_device_detach() must be skipped, all other cleanup (especially device reset and closing the file handle) still needs to be done. There are code paths where usb_host_close() is called with the device in detached state already. This fixes usb-host devices not being released and returned to the host after removing them with device_del. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- usb-linux.c |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/usb-linux.c b/usb-linux.c index 7d4d1d7..f086d57 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -1349,7 +1349,7 @@ static int usb_host_close(USBHostDevice *dev) { int i; -if (dev-fd == -1 || !dev-dev.attached) { +if (dev-fd == -1) { return -1; } @@ -1367,7 +1367,9 @@ static int usb_host_close(USBHostDevice *dev) } async_complete(dev); dev-closing = 0; -usb_device_detach(dev-dev); +if (dev-dev.attached) { +usb_device_detach(dev-dev); +} ioctl(dev-fd, USBDEVFS_RESET); close(dev-fd); dev-fd = -1; -- 1.7.1
Re: [Qemu-devel] [RFC 0/6] block: generic copy-on-read
On Tue, Nov 01, 2011 at 02:28:22PM +, Stefan Hajnoczi wrote: Hi Marcelo, Thanks for your comments on the copy-on-read RFC patches. I am going to send a rebased series out for review/merge. Did you have any other thoughts - I hope I've addressed your questions? Stefan I'm reviewing the generic image streaming series. Should be finished in a couple of days.
Re: [Qemu-devel] [patch] remove unused function arg in qemu_iohandler_poll() and qemu_iohandler_fill()
On 11/01/2011 12:11 AM, Jun Koi wrote: This patch removes unused function argument xfds from qemu_iohandler_poll() and qemu_iohandler_fill() Signed-off-by: Jun Koijunkoi2...@gmail.com diff --git a/iohandler.c b/iohandler.c index 5640d49..9963790 100644 --- a/iohandler.c +++ b/iohandler.c @@ -89,7 +89,7 @@ int qemu_set_fd_handler(int fd, return qemu_set_fd_handler2(fd, NULL, fd_read, fd_write, opaque); } -void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds) Your mailer is munging the patch. Please use git-send-email to avoid this. Regards, Anthony Liguori +void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds) { IOHandlerRecord *ioh; @@ -111,7 +111,7 @@ void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set * } } -void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int ret) +void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, int ret) { if (ret 0) { IOHandlerRecord *pioh, *ioh; diff --git a/main-loop.c b/main-loop.c index 60e9748..7cbb0b0 100644 --- a/main-loop.c +++ b/main-loop.c @@ -446,7 +446,7 @@ int main_loop_wait(int nonblocking) #ifdef CONFIG_SLIRP slirp_select_fill(nfds,rfds,wfds,xfds); #endif -qemu_iohandler_fill(nfds,rfds,wfds,xfds); +qemu_iohandler_fill(nfds,rfds,wfds); glib_select_fill(nfds,rfds,wfds,xfds,tv); if (timeout 0) { @@ -460,7 +460,7 @@ int main_loop_wait(int nonblocking) } glib_select_poll(rfds,wfds,xfds, (ret 0)); -qemu_iohandler_poll(rfds,wfds,xfds, ret); +qemu_iohandler_poll(rfds,wfds, ret); #ifdef CONFIG_SLIRP slirp_select_poll(rfds,wfds,xfds, (ret 0)); #endif diff --git a/main-loop.h b/main-loop.h index 8a716b1..f753c6a 100644 --- a/main-loop.h +++ b/main-loop.h @@ -341,8 +341,8 @@ void qemu_mutex_unlock_iothread(void); /* internal interfaces */ -void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds); -void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int rc); +void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds); +void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, int rc); void qemu_bh_schedule_idle(QEMUBH *bh); int qemu_bh_poll(void); (END)
Re: [Qemu-devel] [PATCH 2/3] usb: change VID/PID for usb-hub and usb-msd to prevent conflict
Am 01.11.2011 15:56, schrieb Gerd Hoffmann: From: Roy Tam roy...@gmail.com Some USB drivers, for example USBASPI.SYS, will skip different type of device which has same VID/PID. The following patch helps preventing usb-msd being skipped by the driver. Sign-off-by: Roy Tam roy...@gmail.com Typo? Andreas Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb-hub.c |4 ++-- hw/usb-msd.c |4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/usb-hub.c b/hw/usb-hub.c index 7b47079..3eb0f1a 100644 --- a/hw/usb-hub.c +++ b/hw/usb-hub.c @@ -127,8 +127,8 @@ static const USBDescDevice desc_device_hub = { static const USBDesc desc_hub = { .id = { -.idVendor = 0, -.idProduct = 0, +.idVendor = 0x0409, +.idProduct = 0x55aa, .bcdDevice = 0x0101, .iManufacturer = STR_MANUFACTURER, .iProduct = STR_PRODUCT, diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 1a0815a..b734177 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -162,8 +162,8 @@ static const USBDescDevice desc_device_high = { static const USBDesc desc = { .id = { -.idVendor = 0, -.idProduct = 0, +.idVendor = 0x46f4, /* CRC16() of QEMU */ +.idProduct = 0x0001, .bcdDevice = 0, .iManufacturer = STR_MANUFACTURER, .iProduct = STR_PRODUCT, -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 2/3] usb: change VID/PID for usb-hub and usb-msd to prevent conflict
On 11/01/11 16:29, Andreas Färber wrote: Am 01.11.2011 15:56, schrieb Gerd Hoffmann: From: Roy Tam roy...@gmail.com Some USB drivers, for example USBASPI.SYS, will skip different type of device which has same VID/PID. The following patch helps preventing usb-msd being skipped by the driver. Sign-off-by: Roy Tam roy...@gmail.com Typo? Yea. Updated comment, pushed to the same location. thanks, Gerd
[Qemu-devel] [PATCH V3 03/13] libxl_qmp: Better error message after a parse error.
By setting the next string to parse after having printed any error messages. Signed-off-by: Anthony PERARD anthony.per...@citrix.com --- tools/libxl/libxl_qmp.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index ef36348..f61a87a 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -403,7 +403,6 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp) *end = '\0'; o = libxl__json_parse(gc, s); -s = end + 2; if (o) { qmp_handle_response(qmp, o); @@ -413,6 +412,8 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp) Parse error of : %s\n, s); return -1; } + +s = end + 2; } else { break; } -- Anthony PERARD
[Qemu-devel] [PATCH V3 04/13] libxl: Introduce dm-version xenstore key.
The all key is /libxl/$domid/dm-version. The /libxl/$domid dir is created with the domain and should be only accessible by the toolstack domain. The function libxl__xs_libxl_path() give this path. This come with libxl__device_model_version_running() helper function. Signed-off-by: Anthony PERARD anthony.per...@citrix.com --- tools/libxl/libxl.c |2 ++ tools/libxl/libxl_create.c | 29 - tools/libxl/libxl_internal.c | 23 +++ tools/libxl/libxl_internal.h |7 +++ tools/libxl/libxl_xshelp.c |9 + 5 files changed, 69 insertions(+), 1 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 064fbc4..22a7795 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -777,6 +777,8 @@ int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid, int force) if (!xs_rm(ctx-xsh, XBT_NULL, dom_path)) LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, xs_rm failed for %s, dom_path); +xs_rm(ctx-xsh, XBT_NULL, libxl__xs_libxl_path(gc, domid)); + libxl__userdata_destroyall(gc, domid); rc = xc_domain_destroy(ctx-xch, domid); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 68d0fc3..9506aa4 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -316,12 +316,14 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info, char *rw_paths[] = { control/shutdown, device, device/suspend/event-channel , data}; char *ro_paths[] = { cpu, memory, device, error, drivers, control, attr, messages }; -char *dom_path, *vm_path; +char *dom_path, *vm_path, *libxl_path; struct xs_permissions roperm[2]; struct xs_permissions rwperm[1]; +struct xs_permissions noperm[1]; xs_transaction_t t = 0; xen_domain_handle_t handle; + assert(!libxl_domid_valid_guest(*domid)); uuid_string = libxl__uuid2string(gc, info-uuid); @@ -368,6 +370,14 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info, goto out; } +libxl_path = libxl__xs_libxl_path(gc, *domid); +if (!libxl_path) { +rc = ERROR_FAIL; +goto out; +} +noperm[0].id = 0; +noperm[0].perms = XS_PERM_NONE; + roperm[0].id = 0; roperm[0].perms = XS_PERM_NONE; roperm[1].id = *domid; @@ -386,6 +396,10 @@ retry_transaction: xs_mkdir(ctx-xsh, t, vm_path); xs_set_permissions(ctx-xsh, t, vm_path, roperm, ARRAY_SIZE(roperm)); +xs_rm(ctx-xsh, t, libxl_path); +xs_mkdir(ctx-xsh, t, libxl_path); +xs_set_permissions(ctx-xsh, t, libxl_path, noperm, ARRAY_SIZE(noperm)); + xs_write(ctx-xsh, t, libxl__sprintf(gc, %s/vm, dom_path), vm_path, strlen(vm_path)); rc = libxl__domain_rename(gc, *domid, 0, info-name, t); if (rc) @@ -429,6 +443,17 @@ retry_transaction: return rc; } +static int store_libxl_entry(libxl__gc *gc, uint32_t domid, + libxl_device_model_info *dm_info) +{ +char *path = NULL; + +path = libxl__xs_libxl_path(gc, domid); +path = libxl__sprintf(gc, %s/dm-version, path); +return libxl__xs_write(gc, XBT_NULL, path, libxl__strdup(gc, +libxl_device_model_version_to_string(dm_info-device_model_version))); +} + static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid_out, int restore_fd) @@ -485,6 +510,8 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, goto error_out; } +store_libxl_entry(gc, domid, dm_info); + for (i = 0; i d_config-num_disks; i++) { ret = libxl_device_disk_add(ctx, domid, d_config-disks[i]); if (ret) { diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index 3993d8e..34edaf3 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -319,6 +319,29 @@ int libxl__fd_set_cloexec(int fd) return fcntl(fd, F_SETFD, flags | FD_CLOEXEC); } +libxl_device_model_version libxl__device_model_version_running(libxl__gc *gc, + uint32_t domid) +{ +char *path = NULL; +char *dm_version = NULL; +libxl_device_model_version value; + +path = libxl__xs_libxl_path(gc, domid); +path = libxl__sprintf(gc, %s/dm-version, path); +dm_version = libxl__xs_read(gc, XBT_NULL, path); +if (!dm_version) { +return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; +} + +if (libxl_device_model_version_from_string(dm_version, value) 0) { +libxl_ctx *ctx = libxl__gc_owner(gc); +LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + fatal: %s contain a wrong value (%s), path, dm_version); +return -1; +} +return value; +} + /* * Local variables: * mode: C diff --git a/tools/libxl/libxl_internal.h
[Qemu-devel] [PATCH V3 09/13] libxl_json: Handle number abrove LONG_MAX.
The integers are now long long in the json_object. If a number (decimal or integer) is too big (or too low), it is stored as it in a string. So for that, we introduce a new type JSON_NUMBER. Signed-off-by: Anthony PERARD anthony.per...@citrix.com --- tools/libxl/libxl_internal.h |6 ++- tools/libxl/libxl_json.c | 74 ++ 2 files changed, 57 insertions(+), 23 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 942d45b..09e0c51 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -468,6 +468,8 @@ typedef enum { JSON_FALSE, JSON_INTEGER, JSON_DOUBLE, +/* number is store in string, it's too big to be a long long or a double */ +JSON_NUMBER, JSON_STRING, JSON_MAP, JSON_ARRAY, @@ -477,7 +479,7 @@ typedef enum { typedef struct libxl__json_object { libxl__json_node_type type; union { -long i; +long long i; double d; char *string; /* List of libxl__json_object */ @@ -536,7 +538,7 @@ flexarray_t *libxl__json_object_get_array(const libxl__json_object *o) else return NULL; } -static inline long libxl__json_object_get_integer(const libxl__json_object *o) +static inline long long libxl__json_object_get_integer(const libxl__json_object *o) { if (libxl__json_object_is_integer(o)) return o-u.i; diff --git a/tools/libxl/libxl_json.c b/tools/libxl/libxl_json.c index 389b697..fd5e2aa 100644 --- a/tools/libxl/libxl_json.c +++ b/tools/libxl/libxl_json.c @@ -14,6 +14,7 @@ #include assert.h #include string.h +#include math.h #include yajl/yajl_parse.h #include yajl/yajl_gen.h @@ -44,6 +45,7 @@ struct libxl__yajl_ctx { # define DEBUG_GEN(ctx, type) yajl_gen_##type(ctx-g) # define DEBUG_GEN_VALUE(ctx, type, value) yajl_gen_##type(ctx-g, value) # define DEBUG_GEN_STRING(ctx, str, n) yajl_gen_string(ctx-g, str, n) +# define DEBUG_GEN_NUMBER(ctx, str, n) yajl_gen_number(ctx-g, str, n) # define DEBUG_GEN_REPORT(yajl_ctx) \ do { \ const unsigned char *buf = NULL; \ @@ -60,6 +62,7 @@ struct libxl__yajl_ctx { # define DEBUG_GEN(ctx, type) ((void)0) # define DEBUG_GEN_VALUE(ctx, type, value) ((void)0) # define DEBUG_GEN_STRING(ctx, value, lenght) ((void)0) +# define DEBUG_GEN_NUMBER(ctx, value, lenght) ((void)0) # define DEBUG_GEN_REPORT(ctx) ((void)0) #endif @@ -363,6 +366,7 @@ void libxl__json_object_free(libxl__gc *gc, libxl__json_object *obj) return; switch (obj-type) { case JSON_STRING: +case JSON_NUMBER: free(obj-u.string); break; case JSON_MAP: { @@ -504,36 +508,64 @@ static int json_callback_boolean(void *opaque, int boolean) return 1; } -static int json_callback_integer(void *opaque, long value) +static bool is_decimal(const char *s, unsigned len) +{ +const char *end = s + len; +for (; s end; s++) { +if (*s == '.') +return true; +} +return false; +} + +static int json_callback_number(void *opaque, const char *s, unsigned int len) { libxl__yajl_ctx *ctx = opaque; -libxl__json_object *obj; +libxl__json_object *obj = NULL; +char *t = NULL; -DEBUG_GEN_VALUE(ctx, integer, value); +DEBUG_GEN_NUMBER(ctx, s, len); -if ((obj = json_object_alloc(ctx-gc, JSON_INTEGER)) == NULL) -return 0; -obj-u.i = value; +if (is_decimal(s, len)) { +double d = strtod(s, NULL); -if (json_object_append_to(ctx-gc, obj, ctx-current) == -1) { -libxl__json_object_free(ctx-gc, obj); -return 0; -} +if ((d == HUGE_VAL || d == HUGE_VAL) errno == ERANGE) { +goto error; +} -return 1; -} +if ((obj = json_object_alloc(ctx-gc, JSON_DOUBLE)) == NULL) +return 0; +obj-u.d = d; +} else { +long long i = strtoll(s, NULL, 10); -static int json_callback_double(void *opaque, double value) -{ -libxl__yajl_ctx *ctx = opaque; -libxl__json_object *obj; +if ((i == LLONG_MIN || i == LLONG_MAX) errno == ERANGE) { +goto error; +} -DEBUG_GEN_VALUE(ctx, double, value); +if ((obj = json_object_alloc(ctx-gc, JSON_INTEGER)) == NULL) +return 0; +obj-u.i = i; +} +goto out; -if ((obj = json_object_alloc(ctx-gc, JSON_DOUBLE)) == NULL) +error: +/* If the conversion fail, we just store the original string. */ +if ((obj = json_object_alloc(ctx-gc, JSON_NUMBER)) == NULL) return 0; -obj-u.d = value; +t = malloc(len + 1); +if (t == NULL) { +LIBXL__LOG_ERRNO(libxl__gc_owner(ctx-gc), LIBXL__LOG_ERROR, + Failed to allocate); +return 0; +} +strncpy(t, s, len); +t[len] = 0; + +obj-u.string = t; + +out: if (json_object_append_to(ctx-gc, obj,
Re: [Qemu-devel] [PATCH] Error check find_ram_offset
On 10/31/2011 09:54 AM, Alex Williamson wrote: Spotted via code review, we initialize offset to 0 to avoid a compiler warning, but in the unlikely case that offset is never set to something else, we should abort instead of return a value that will almost certainly cause problems. Signed-off-by: Alex Williamsonalex.william...@redhat.com Applied. Thanks. Regards, Anthony Liguori --- exec.c | 11 +-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 9dc4edb..70f6fb8 100644 --- a/exec.c +++ b/exec.c @@ -2874,7 +2874,7 @@ static void *file_ram_alloc(RAMBlock *block, static ram_addr_t find_ram_offset(ram_addr_t size) { RAMBlock *block, *next_block; -ram_addr_t offset = 0, mingap = RAM_ADDR_MAX; +ram_addr_t offset = RAM_ADDR_MAX, mingap = RAM_ADDR_MAX; if (QLIST_EMPTY(ram_list.blocks)) return 0; @@ -2890,10 +2890,17 @@ static ram_addr_t find_ram_offset(ram_addr_t size) } } if (next - end= size next - end mingap) { -offset = end; +offset = end; mingap = next - end; } } + +if (offset == RAM_ADDR_MAX) { +fprintf(stderr, Failed to find gap of requested size: % PRIu64 \n, +(uint64_t)size); +abort(); +} + return offset; }
Re: [Qemu-devel] [PATCH v3 0/3] TLS abstraction layer for thread-local cpu_single_env on Linux
On 10/28/2011 04:52 AM, Peter Maydell wrote: These patches add enough of the TLS abstraction layer to allow us to make cpu_single_env thread-local on Linux systems. This fixes the regression described in bug 823902 for the 1.0 release; we can add the Win32 and POSIX implementations later. I haven't included Paolo's Prepare Windows port for thread-local cpu_single_env patch -- it would be safe to do so but it isn't necessary until we actually implement TLS for Win32. Applied all. Thanks. Regards, Anthony Liguori Changes v1-v2: * fix Paolo's email address * split the darwin-user change out into a separate patch * drop the 'tls_' prefix from the cpu_single_env tls var name Changes v2-v3: * minor rearrangement of copyright notice in comment * added a missing Signed-off-by * fixed the name of the multiple-include-guard #define Paolo Bonzini (2): darwin-user/main.c: Drop unused cpu_single_env definition Make cpu_single_env thread-local Peter Maydell (1): qemu-tls.h: Add abstraction layer for TLS variables cpu-all.h |4 +++- darwin-user/main.c |2 -- exec.c |2 +- qemu-tls.h | 52 4 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 qemu-tls.h
Re: [Qemu-devel] [PATCH] MAINTAINERS: Add PReP maintainer
On 10/31/2011 06:03 PM, Andreas Färber wrote: Officially take on maintainership for PReP and upgrade to Odd Fixes. Signed-off-by: Andreas Färberandreas.faer...@web.de Cc: Alexander Grafag...@suse.de Cc: Hervé Poussineauhpous...@reactos.org Applied. Thanks. Regards, Anthony Liguori --- MAINTAINERS |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 4535eeb..bccdd4f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -303,9 +303,9 @@ M: Alexander Grafag...@suse.de S: Maintained F: hw/ppc_oldworld.c -Prep -M: qemu-devel@nongnu.org -S: Orphan +PReP +M: Andreas Färberandreas.faer...@web.de +S: Odd Fixes F: hw/ppc_prep.c SH4 Machines
[Qemu-devel] [PATCH V3 07/13] libxl_qmp: Always insert a command id in the callback_list.
Because the function qmp_synchronous_send rely on the presence of the id in the callback_list. Signed-off-by: Anthony PERARD anthony.per...@citrix.com Acked-by: Ian Campbell ian.campb...@citrix.com --- tools/libxl/libxl_qmp.c | 34 ++ 1 files changed, 18 insertions(+), 16 deletions(-) diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 43c7d04..47129c3 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -213,7 +213,9 @@ static void qmp_handle_error_response(libxl__qmp_handler *qmp, resp = libxl__json_map_get(desc, resp, JSON_STRING); if (pp) { -pp-callback(qmp, NULL, pp-opaque); +if (pp-callback) { +pp-callback(qmp, NULL, pp-opaque); +} if (pp-id == qmp-wait_for_id) { /* tell that the id have been processed */ qmp-wait_for_id = 0; @@ -245,9 +247,11 @@ static int qmp_handle_response(libxl__qmp_handler *qmp, callback_id_pair *pp = qmp_get_callback_from_id(qmp, resp); if (pp) { -pp-callback(qmp, - libxl__json_map_get(return, resp, JSON_ANY), - pp-opaque); +if (pp-callback) { +pp-callback(qmp, + libxl__json_map_get(return, resp, JSON_ANY), + pp-opaque); +} if (pp-id == qmp-wait_for_id) { /* tell that the id have been processed */ qmp-wait_for_id = 0; @@ -438,6 +442,7 @@ static int qmp_send(libxl__qmp_handler *qmp, unsigned int len = 0; yajl_gen_status s; yajl_gen hand; +callback_id_pair *elm = NULL; hand = yajl_gen_alloc(conf, NULL); if (!hand) { @@ -463,19 +468,16 @@ static int qmp_send(libxl__qmp_handler *qmp, return -1; } -if (callback) { -callback_id_pair *elm = malloc(sizeof (callback_id_pair)); -if (elm == NULL) { -LIBXL__LOG_ERRNO(qmp-ctx, LIBXL__LOG_ERROR, - Failed to allocate a QMP callback); -yajl_gen_free(hand); -return -1; -} -elm-id = qmp-last_id_used; -elm-callback = callback; -elm-opaque = opaque; -SIMPLEQ_INSERT_TAIL(qmp-callback_list, elm, next); +elm = malloc(sizeof (callback_id_pair)); +if (elm == NULL) { +LIBXL__LOG_ERRNO(qmp-ctx, LIBXL__LOG_ERROR, + Failed to allocate a QMP callback); +goto error; } +elm-id = qmp-last_id_used; +elm-callback = callback; +elm-opaque = opaque; +SIMPLEQ_INSERT_TAIL(qmp-callback_list, elm, next); LIBXL__LOG(qmp-ctx, LIBXL__LOG_DEBUG, next qmp command: '%s', buf); -- Anthony PERARD
Re: [Qemu-devel] [PATCH V3 00/13] libxl: QMP client improvement + pci passthrougth insert through QMP
Oops, I have sent this series to too many ml :-( On Tue, Nov 1, 2011 at 16:07, Anthony PERARD anthony.per...@citrix.com wrote: This patch series improves the QMP client in lib XenLight to be able to insert a PCI passthrough device with the upstream QEMU. This require to apply a patch series for QEMU (named Xen PCI Passthrough). -- Anthony PERARD
Re: [Qemu-devel] [PATCH] Simplify cpu_exec_all to tcg_exec_all
On 09/26/2011 02:40 AM, Jan Kiszka wrote: After the removal of the non-threaded mode cpu_exec_all is now only used by TCG. Refactor it accordingly, also dropping its unused return value. Signed-off-by: Jan Kiszkajan.kis...@siemens.com Applied. Thanks. Regards, Anthony Liguori --- cpus.c | 14 +- cpus.h |1 - 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/cpus.c b/cpus.c index 8978779..f983033 100644 --- a/cpus.c +++ b/cpus.c @@ -664,6 +664,8 @@ static void *qemu_kvm_cpu_thread_fn(void *arg) return NULL; } +static void tcg_exec_all(void); + static void *qemu_tcg_cpu_thread_fn(void *arg) { CPUState *env = arg; @@ -685,7 +687,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) } while (1) { -cpu_exec_all(); +tcg_exec_all(); if (use_icount qemu_next_icount_deadline()= 0) { qemu_notify_event(); } @@ -925,7 +927,7 @@ static int tcg_cpu_exec(CPUState *env) return ret; } -bool cpu_exec_all(void) +static void tcg_exec_all(void) { int r; @@ -942,12 +944,7 @@ bool cpu_exec_all(void) (env-singlestep_enabled SSTEP_NOTIMER) == 0); if (cpu_can_run(env)) { -if (kvm_enabled()) { -r = kvm_cpu_exec(env); -qemu_kvm_eat_signals(env); -} else { -r = tcg_cpu_exec(env); -} +r = tcg_cpu_exec(env); if (r == EXCP_DEBUG) { cpu_handle_guest_debug(env); break; @@ -957,7 +954,6 @@ bool cpu_exec_all(void) } } exit_request = 0; -return !all_cpu_threads_idle(); } void set_numa_modes(void) diff --git a/cpus.h b/cpus.h index 5885885..bb91684 100644 --- a/cpus.h +++ b/cpus.h @@ -15,7 +15,6 @@ void cpu_synchronize_all_post_init(void); /* vl.c */ extern int smp_cores; extern int smp_threads; -bool cpu_exec_all(void); void set_numa_modes(void); void set_cpu_log(const char *optarg); void set_cpu_log_filename(const char *optarg);
Re: [Qemu-devel] [PATCH v2] Support running QEMU on Valgrind
On 10/31/2011 03:29 PM, Stefan Weil wrote: Valgrind is a tool which can automatically detect many kinds of bugs. Running QEMU on Valgrind with x86_64 hosts was not possible because Valgrind aborts when memalign is called with an alignment larger than 1 MiB. QEMU normally uses 2 MiB on Linux x86_64. Now the alignment is reduced to the page size when QEMU is running on Valgrind. v2: Instead of using the macro RUNNING_ON_VALGRIND from valgrind.h, the patch now uses a hack from libvirt which tests for the pre-loaded vgpreload_*.so shared libraries. This avoids the need for valgrind.h. Signed-off-by: Stefan Weils...@weilnetz.de Applied. Thanks. Regards, Anthony Liguori --- oslib-posix.c | 22 +++--- 1 files changed, 19 insertions(+), 3 deletions(-) diff --git a/oslib-posix.c b/oslib-posix.c index dbc8ee8..6f29762 100644 --- a/oslib-posix.c +++ b/oslib-posix.c @@ -36,8 +36,11 @@ extern int daemon(int, int); #endif #if defined(__linux__) defined(__x86_64__) - /* Use 2MB alignment so transparent hugepages can be used by KVM */ + /* Use 2 MiB alignment so transparent hugepages can be used by KVM. + Valgrind does not support alignments larger than 1 MiB, + therefore we need special code which handles running on Valgrind. */ # define QEMU_VMALLOC_ALIGN (512 * 4096) +# define CONFIG_VALGRIND #else # define QEMU_VMALLOC_ALIGN getpagesize() #endif @@ -47,7 +50,11 @@ extern int daemon(int, int); #include trace.h #include qemu_socket.h - +#if defined(CONFIG_VALGRIND) +static int running_on_valgrind = -1; +#else +# define running_on_valgrind 0 +#endif int qemu_daemon(int nochdir, int noclose) { @@ -89,7 +96,16 @@ void *qemu_vmalloc(size_t size) void *ptr; size_t align = QEMU_VMALLOC_ALIGN; -if (size align) { +#if defined(CONFIG_VALGRIND) +if (running_on_valgrind 0) { +/* First call, test whether we are running on Valgrind. + This is a substitute for RUNNING_ON_VALGRIND from valgrind.h. */ +const char *ld = getenv(LD_PRELOAD); +running_on_valgrind = (ld != NULL strstr(ld, vgpreload)); +} +#endif + +if (size align || running_on_valgrind) { align = getpagesize(); } ptr = qemu_memalign(align, size);
[Qemu-devel] [PATCH V3 12/13] libxl_qmp: Introduce libxl__qmp_pci_del
To remove a pci passthough device from QEMU (upstream). Signed-off-by: Anthony PERARD anthony.per...@citrix.com --- tools/libxl/libxl_internal.h |2 ++ tools/libxl/libxl_qmp.c | 35 +++ 2 files changed, 37 insertions(+), 0 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 718a417..5123578 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -450,6 +450,8 @@ _hidden libxl__qmp_handler *libxl__qmp_initialize(libxl_ctx *ctx, /* ask to QEMU the serial port information and store it in xenstore. */ _hidden int libxl__qmp_query_serial(libxl__qmp_handler *qmp); _hidden int libxl__qmp_pci_add(libxl__gc *gc, int d, libxl_device_pci *pcidev); +_hidden int libxl__qmp_pci_del(libxl__gc *gc, int domid, + libxl_device_pci *pcidev); /* close and free the QMP handler */ _hidden void libxl__qmp_close(libxl__qmp_handler *qmp); /* remove the socket file, if the file has already been removed, diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 07ccf7a..e7eb8cc 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -713,6 +713,41 @@ int libxl__qmp_pci_add(libxl__gc *gc, int domid, libxl_device_pci *pcidev) return rc; } +static int qmp_device_del(libxl__gc *gc, int domid, char *id) +{ +libxl__qmp_handler *qmp = NULL; +flexarray_t *parameters = NULL; +libxl_key_value_list args = NULL; +int rc = 0; + +qmp = libxl__qmp_initialize(libxl__gc_owner(gc), domid); +if (!qmp) +return -1; + +parameters = flexarray_make(2, 1); +flexarray_append_pair(parameters, id, id); +args = libxl__xs_kvs_of_flexarray(gc, parameters, parameters-count); +if (!args) +return -1; + +rc = qmp_synchronous_send(qmp, device_del, args, + NULL, NULL, qmp-timeout); + +flexarray_free(parameters); +libxl__qmp_close(qmp); +return rc; +} + +int libxl__qmp_pci_del(libxl__gc *gc, int domid, libxl_device_pci *pcidev) +{ +char *id = NULL; + +id = libxl__sprintf(gc, PCI_PT_QDEV_ID, +pcidev-bus, pcidev-dev, pcidev-func); + +return qmp_device_del(gc, domid, id); +} + int libxl__qmp_initializations(libxl_ctx *ctx, uint32_t domid) { libxl__qmp_handler *qmp = NULL; -- Anthony PERARD
Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin
Am 01.11.2011 09:09, schrieb Eric Sunshine: Perhaps the following alternative solution would be more palatable? It's still tremendously ugly, but is localized to cocoa.m, thus less intrusive. -- 8 -- Subject: [PATCH] softfloat: Avoid uint16 type conflict on Darwin cocoa.m includes Security/cssmconfig.h indirectly via Cocoa/Cocoa.h. cssmconfig.h defines type uint16 which unfortunately conflicts with the definition in qemu's softfloat.h, thus resulting in compilation failure. To work around the problem, #define _UINT16, which informs cssmconfig.h that uint16 is already defined and that it should not apply its own definition. Thanks for the suggestion! _UINT16 is an interesting suggestion, however softfloat's uint16 is not uint16_t but int, so I'd rather not do it that way around. (I had also decided against the AIX path of never defining uint16 and always using system definitions, since that wouldn't work outside Cocoa code.) Do you have any thoughts about the include path issue? If we could keep QEMU code from getting into #import Cocoa/Cocoa.h then we could redefine the system type instead, in cocoa.m. Andreas
[Qemu-devel] [PATCH V3 11/13] libxl: Use QMP to insert a passthrough device when using upstream QEMU
Also move the xenstore specif code to a new function and add a message if sscanf fail. Signed-off-by: Anthony PERARD anthony.per...@citrix.com --- tools/libxl/libxl_pci.c | 74 +-- 1 files changed, 52 insertions(+), 22 deletions(-) diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 33dd060..207ee33 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -599,11 +599,52 @@ static int pci_ins_check(libxl__gc *gc, uint32_t domid, const char *state, void return 1; } -static int do_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting) +static int qemu_pci_add_xenstore(libxl__gc *gc, uint32_t domid, + libxl_device_pci *pcidev) { libxl_ctx *ctx = libxl__gc_owner(gc); +int rc = 0; char *path; char *state, *vdevfn; + +path = libxl__sprintf(gc, /local/domain/0/device-model/%d/state, domid); +state = libxl__xs_read(gc, XBT_NULL, path); +path = libxl__sprintf(gc, /local/domain/0/device-model/%d/parameter, + domid); +if (pcidev-vdevfn) { +libxl__xs_write(gc, XBT_NULL, path, PCI_BDF_VDEVFN, +pcidev-domain, pcidev-bus, pcidev-dev, +pcidev-func, pcidev-vdevfn); +} else { +libxl__xs_write(gc, XBT_NULL, path, PCI_BDF, pcidev-domain, +pcidev-bus, pcidev-dev, pcidev-func); +} +path = libxl__sprintf(gc, /local/domain/0/device-model/%d/command, + domid); +xs_write(ctx-xsh, XBT_NULL, path, pci-ins, strlen(pci-ins)); +rc = libxl__wait_for_device_model(gc, domid, NULL, NULL, + pci_ins_check, state); +path = libxl__sprintf(gc, /local/domain/0/device-model/%d/parameter, + domid); +vdevfn = libxl__xs_read(gc, XBT_NULL, path); +path = libxl__sprintf(gc, /local/domain/0/device-model/%d/state, + domid); +if ( rc 0 ) +LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + qemu refused to add device: %s, vdevfn); +else if ( sscanf(vdevfn, 0x%x, pcidev-vdevfn) != 1 ) { +LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + wrong format for the vdevfn: '%s', vdevfn); +rc = -1; +} +xs_write(ctx-xsh, XBT_NULL, path, state, strlen(state)); + +return rc; +} + +static int do_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting) +{ +libxl_ctx *ctx = libxl__gc_owner(gc); int rc, hvm = 0; switch (libxl__domain_type(gc, domid)) { @@ -613,27 +654,16 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, i NULL, NULL, NULL) 0) { return ERROR_FAIL; } -path = libxl__sprintf(gc, /local/domain/0/device-model/%d/state, domid); -state = libxl__xs_read(gc, XBT_NULL, path); -path = libxl__sprintf(gc, /local/domain/0/device-model/%d/parameter, domid); -if (pcidev-vdevfn) -libxl__xs_write(gc, XBT_NULL, path, PCI_BDF_VDEVFN, pcidev-domain, - pcidev-bus, pcidev-dev, pcidev-func, pcidev-vdevfn); -else -libxl__xs_write(gc, XBT_NULL, path, PCI_BDF, pcidev-domain, - pcidev-bus, pcidev-dev, pcidev-func); -path = libxl__sprintf(gc, /local/domain/0/device-model/%d/command, domid); -xs_write(ctx-xsh, XBT_NULL, path, pci-ins, strlen(pci-ins)); -rc = libxl__wait_for_device_model(gc, domid, NULL, NULL, - pci_ins_check, state); -path = libxl__sprintf(gc, /local/domain/0/device-model/%d/parameter, domid); -vdevfn = libxl__xs_read(gc, XBT_NULL, path); -path = libxl__sprintf(gc, /local/domain/0/device-model/%d/state, domid); -if ( rc 0 ) -LIBXL__LOG(ctx, LIBXL__LOG_ERROR, qemu refused to add device: %s, vdevfn); -else if ( sscanf(vdevfn, 0x%x, pcidev-vdevfn) != 1 ) -rc = -1; -xs_write(ctx-xsh, XBT_NULL, path, state, strlen(state)); +switch (libxl__device_model_version_running(gc, domid)) { +case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: +rc = qemu_pci_add_xenstore(gc, domid, pcidev); +break; +case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: +rc = libxl__qmp_pci_add(gc, domid, pcidev); +break; +default: +return ERROR_INVAL; +} if ( rc ) return ERROR_FAIL; break; -- Anthony PERARD
[Qemu-devel] [qemu-kvm unittest regression] Re: Autotest | Job ID: 2011 Upstream qemu-kvm.git sanity 11-01-2011 00:04:02 | Status: 1 Completed | Success Rate: 94.74 %
On 11/01/2011 12:17 PM, kvm-autotest wrote: Job ID: 2011 Job name: Upstream qemu-kvm.git sanity 11-01-2011 00:04:02 Summary: Host: Status: Completed Status: 1 Completed Execution time (HH:MM:SS): 01:17:02 User tests executed: 19 User tests passed: 18 User tests failed: 1 User tests success rate: 94.74 % Failures: Test Name Status Reason kvm.qemu-kvm-git.unittests FAIL Unit tests failed: emulator Hi Marcelo, Avi: We've seen emulator unittest failures during the last couple of jobs of qemu-kvm.git userspace + kvm.git kernel. Relevant hashes for the last failure seen: 11/01 09:33:59 INFO |virt_utils:0501| Commit hash for git://github.com/avikivity/kvm.git is b796a09c5d808f4013f27ad45953db604dac18fd (tag v3.1-rc4-10168-gb796a09) 11/01 09:50:57 DEBUG|virt_utils:2587| Git repo qemu_kvm uri: git://github.com/avikivity/qemu.git 11/01 09:51:52 INFO |virt_utils:2531| Commit hash for qemu_kvm is 7879db7e9c09b92d9af1c143fbe2cc212ec89e4b (no tag found) Cheers, Lucas
Re: [Qemu-devel] [PATCH] KVM: Use -cpu host as default on x86
On 10/13/2011 10:24 AM, Alexander Graf wrote: When running QEMU without -cpu parameter, the user usually wants a sane default. So far, we're using the qemu64/qemu32 CPU type, which basically means the maximum TCG can emulate. That's a really good default when using TCG, but when running with KVM we much rather want a default saying the maximum KVM can support. Fortunately we already have such a CPU type. It's called host. All we need to do is to select it by default when not getting a -cpu passed in. This fixes a lot of subtile breakage in the GNU toolchain (libgmp) which hicks up on QEMU's non-existent CPU models. Signed-off-by: Alexander Grafag...@suse.de Need to make sure that older machine types (i.e. pc-0.15, pc-0.14) default to the appropriate CPU model. Regards, Anthony Liguori --- hw/pc.c | 10 +++--- hw/pc.h |2 +- hw/pc_piix.c |2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index 203627d..e0c48f2 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -941,17 +941,21 @@ static CPUState *pc_new_cpu(const char *cpu_model) return env; } -void pc_cpus_init(const char *cpu_model) +void pc_cpus_init(const char *cpu_model, int kvm_enabled) { int i; /* init CPUs */ if (cpu_model == NULL) { +if (kvm_enabled) { +cpu_model = host; +} else { #ifdef TARGET_X86_64 -cpu_model = qemu64; +cpu_model = qemu64; #else -cpu_model = qemu32; +cpu_model = qemu32; #endif +} } for(i = 0; i smp_cpus; i++) { diff --git a/hw/pc.h b/hw/pc.h index f3e21b6..b5519ff 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -130,7 +130,7 @@ void pc_register_ferr_irq(qemu_irq irq); void pc_cmos_set_s3_resume(void *opaque, int irq, int level); void pc_acpi_smi_interrupt(void *opaque, int irq, int level); -void pc_cpus_init(const char *cpu_model); +void pc_cpus_init(const char *cpu_model, int kvm_enabled); void pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline, diff --git a/hw/pc_piix.c b/hw/pc_piix.c index ce1c87f..a080191 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -99,7 +99,7 @@ static void pc_init1(MemoryRegion *system_memory, MemoryRegion *pci_memory; MemoryRegion *rom_memory; -pc_cpus_init(cpu_model); +pc_cpus_init(cpu_model, kvm_enabled()); if (kvmclock_enabled) { kvmclock_create();
[Qemu-devel] [PATCH V3 06/13] libxl_qmp: Introduce list of arguments to qmp_send
Signed-off-by: Anthony PERARD anthony.per...@citrix.com Acked-by: Ian Campbell ian.campb...@citrix.com --- tools/libxl/libxl_qmp.c | 16 +++- 1 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index ddc0a4d..43c7d04 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -72,7 +72,7 @@ struct libxl__qmp_handler { }; static int qmp_send(libxl__qmp_handler *qmp, -const char *cmd, +const char *cmd, libxl_key_value_list *args, qmp_callback_t callback, void *opaque); static const int QMP_SOCKET_CONNECT_TIMEOUT = 5; @@ -161,7 +161,8 @@ static int qmp_capabilities_callback(libxl__qmp_handler *qmp, static int enable_qmp_capabilities(libxl__qmp_handler *qmp) { -return qmp_send(qmp, qmp_capabilities, qmp_capabilities_callback, NULL); +return qmp_send(qmp, qmp_capabilities, NULL, +qmp_capabilities_callback, NULL); } /* @@ -429,7 +430,7 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp) } static int qmp_send(libxl__qmp_handler *qmp, -const char *cmd, +const char *cmd, libxl_key_value_list *args, qmp_callback_t callback, void *opaque) { yajl_gen_config conf = { 0, NULL }; @@ -448,6 +449,10 @@ static int qmp_send(libxl__qmp_handler *qmp, libxl__yajl_gen_asciiz(hand, cmd); libxl__yajl_gen_asciiz(hand, id); yajl_gen_integer(hand, ++qmp-last_id_used); +if (args) { +libxl__yajl_gen_asciiz(hand, arguments); +libxl_key_value_list_gen_json(hand, args); +} yajl_gen_map_close(hand); s = yajl_gen_get_buf(hand, buf, len); @@ -491,6 +496,7 @@ error: } static int qmp_synchronous_send(libxl__qmp_handler *qmp, const char *cmd, +libxl_key_value_list *args, qmp_callback_t callback, void *opaque, int ask_timeout) { @@ -498,7 +504,7 @@ static int qmp_synchronous_send(libxl__qmp_handler *qmp, const char *cmd, int ret = 0; libxl__gc gc = LIBXL_INIT_GC(qmp-ctx); -id = qmp_send(qmp, cmd, callback, opaque); +id = qmp_send(qmp, cmd, args, callback, opaque); if (id = 0) { return -1; } @@ -586,7 +592,7 @@ void libxl__qmp_cleanup(libxl__gc *gc, uint32_t domid) int libxl__qmp_query_serial(libxl__qmp_handler *qmp) { -return qmp_synchronous_send(qmp, query-chardev, +return qmp_synchronous_send(qmp, query-chardev, NULL, register_serials_chardev_callback, NULL, qmp-timeout); } -- Anthony PERARD
[Qemu-devel] [PATCH V3 05/13] libxl_qmp: Introduce an opaque argument to the callbacks.
Signed-off-by: Anthony PERARD anthony.per...@citrix.com Acked-by: Ian Campbell ian.campb...@citrix.com --- tools/libxl/libxl_qmp.c | 30 +++--- 1 files changed, 19 insertions(+), 11 deletions(-) diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index f61a87a..ddc0a4d 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -43,11 +43,13 @@ #define QMP_RECEIVE_BUFFER_SIZE 4096 typedef int (*qmp_callback_t)(libxl__qmp_handler *qmp, - const libxl__json_object *tree); + const libxl__json_object *tree, + void *opaque); typedef struct callback_id_pair { int id; qmp_callback_t callback; +void *opaque; SIMPLEQ_ENTRY(callback_id_pair) next; } callback_id_pair; @@ -70,7 +72,8 @@ struct libxl__qmp_handler { }; static int qmp_send(libxl__qmp_handler *qmp, -const char *cmd, qmp_callback_t callback); +const char *cmd, +qmp_callback_t callback, void *opaque); static const int QMP_SOCKET_CONNECT_TIMEOUT = 5; @@ -100,7 +103,8 @@ static int store_serial_port_info(libxl__qmp_handler *qmp, } static int register_serials_chardev_callback(libxl__qmp_handler *qmp, - const libxl__json_object *o) + const libxl__json_object *o, + void *unused) { const libxl__json_object *obj = NULL; const libxl__json_object *label = NULL; @@ -144,7 +148,7 @@ static int register_serials_chardev_callback(libxl__qmp_handler *qmp, } static int qmp_capabilities_callback(libxl__qmp_handler *qmp, - const libxl__json_object *o) + const libxl__json_object *o, void *unused) { qmp-connected = true; @@ -157,7 +161,7 @@ static int qmp_capabilities_callback(libxl__qmp_handler *qmp, static int enable_qmp_capabilities(libxl__qmp_handler *qmp) { -return qmp_send(qmp, qmp_capabilities, qmp_capabilities_callback); +return qmp_send(qmp, qmp_capabilities, qmp_capabilities_callback, NULL); } /* @@ -208,7 +212,7 @@ static void qmp_handle_error_response(libxl__qmp_handler *qmp, resp = libxl__json_map_get(desc, resp, JSON_STRING); if (pp) { -pp-callback(qmp, NULL); +pp-callback(qmp, NULL, pp-opaque); if (pp-id == qmp-wait_for_id) { /* tell that the id have been processed */ qmp-wait_for_id = 0; @@ -241,7 +245,8 @@ static int qmp_handle_response(libxl__qmp_handler *qmp, if (pp) { pp-callback(qmp, - libxl__json_map_get(return, resp, JSON_ANY)); + libxl__json_map_get(return, resp, JSON_ANY), + pp-opaque); if (pp-id == qmp-wait_for_id) { /* tell that the id have been processed */ qmp-wait_for_id = 0; @@ -424,7 +429,8 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp) } static int qmp_send(libxl__qmp_handler *qmp, -const char *cmd, qmp_callback_t callback) +const char *cmd, +qmp_callback_t callback, void *opaque) { yajl_gen_config conf = { 0, NULL }; const unsigned char *buf; @@ -462,6 +468,7 @@ static int qmp_send(libxl__qmp_handler *qmp, } elm-id = qmp-last_id_used; elm-callback = callback; +elm-opaque = opaque; SIMPLEQ_INSERT_TAIL(qmp-callback_list, elm, next); } @@ -484,13 +491,14 @@ error: } static int qmp_synchronous_send(libxl__qmp_handler *qmp, const char *cmd, -qmp_callback_t callback, int ask_timeout) +qmp_callback_t callback, void *opaque, +int ask_timeout) { int id = 0; int ret = 0; libxl__gc gc = LIBXL_INIT_GC(qmp-ctx); -id = qmp_send(qmp, cmd, callback); +id = qmp_send(qmp, cmd, callback, opaque); if (id = 0) { return -1; } @@ -580,7 +588,7 @@ int libxl__qmp_query_serial(libxl__qmp_handler *qmp) { return qmp_synchronous_send(qmp, query-chardev, register_serials_chardev_callback, -qmp-timeout); +NULL, qmp-timeout); } int libxl__qmp_initializations(libxl_ctx *ctx, uint32_t domid) -- Anthony PERARD
[Qemu-devel] [PATCH V3 00/13] libxl: QMP client improvement + pci passthrougth insert through QMP
This patch series improves the QMP client in lib XenLight to be able to insert a PCI passthrough device with the upstream QEMU. This require to apply a patch series for QEMU (named Xen PCI Passthrough). The first three patches are fix. The next patch creates a key in xenstore with the version of the running device model, here: /libxl/$domid/dm-version Changed since v2: dm-version xenstore key patch: - small coding style improvement - libxl__device_model_version_running() now return an error on unexpected value in /libxl/$domid/dm-version qmp_request_context patch: - rename handle to context - the context is now only used between qmp_sync.._send and qmp_send - return code of a callback is now return by qmp_sync.._send() Handle number abrove LONG_MAX patch: - the new callback now also handle double. two new patches to do a pci-detatch. Change v1-v2: - 3 new patches, with small fix. - add a structure in qmp, qmp_request_handle, to carry the return code of a callback. - the xenstore key for the dm-version is now in /libxl/$domid, instead of /local/domain/$domid - new patch to parse number bigger than LONG_MAX for json. - an user specified vdevfn for a pci passthrough devices is now handle. - in the last patch, the code to handle a pci-add through xenstore have is own function. that help a bit to keep the code under 80col. Anthony PERARD (13): libxl_qmp: Fix return check of fcntl libxl_json: Check the parser status before to call parse_complete libxl_qmp: Better error message after a parse error. libxl: Introduce dm-version xenstore key. libxl_qmp: Introduce an opaque argument to the callbacks. libxl_qmp: Introduce list of arguments to qmp_send libxl_qmp: Always insert a command id in the callback_list. libxl_qmp: Introduce qmp_request_context. libxl_json: Handle number abrove LONG_MAX. libxl_qmp: Introduce libxl__qmp_pci_add. libxl: Use QMP to insert a passthrough device when using upstream QEMU libxl_qmp: Introduce libxl__qmp_pci_del libxl: Remove a passthrough device through QMP. tools/libxl/libxl.c |2 + tools/libxl/libxl_create.c | 29 +- tools/libxl/libxl_internal.c | 23 tools/libxl/libxl_internal.h | 19 +++- tools/libxl/libxl_json.c | 111 +--- tools/libxl/libxl_pci.c | 143 + tools/libxl/libxl_qmp.c | 236 +++-- tools/libxl/libxl_xshelp.c |9 ++ 8 files changed, 450 insertions(+), 122 deletions(-) -- Anthony PERARD
[Qemu-devel] [PATCH V3 01/13] libxl_qmp: Fix return check of fcntl
Signed-off-by: Anthony PERARD anthony.per...@citrix.com --- tools/libxl/libxl_qmp.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 618f20f..ef36348 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -296,7 +296,7 @@ static int qmp_open(libxl__qmp_handler *qmp, const char *qmp_socket_path, if (qmp-qmp_fd 0) { return -1; } -if ((flags = fcntl(qmp-qmp_fd, F_GETFL)) == 1) { +if ((flags = fcntl(qmp-qmp_fd, F_GETFL)) == -1) { flags = 0; } if (fcntl(qmp-qmp_fd, F_SETFL, flags | O_NONBLOCK) == -1) { -- Anthony PERARD
[Qemu-devel] [PATCH V3 08/13] libxl_qmp: Introduce qmp_request_context.
This structure helps to track the return code of a callback. It's only used between qmp_synchronous_send and qmp_send. Now, qmp_synchronous_send will return the rc of the callback if there is no error. Signed-off-by: Anthony PERARD anthony.per...@citrix.com --- tools/libxl/libxl_qmp.c | 49 -- 1 files changed, 34 insertions(+), 15 deletions(-) diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 47129c3..6d80538 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -46,10 +46,15 @@ typedef int (*qmp_callback_t)(libxl__qmp_handler *qmp, const libxl__json_object *tree, void *opaque); +typedef struct qmp_request_context { +int rc; +} qmp_request_context; + typedef struct callback_id_pair { int id; qmp_callback_t callback; void *opaque; +qmp_request_context *context; SIMPLEQ_ENTRY(callback_id_pair) next; } callback_id_pair; @@ -73,7 +78,8 @@ struct libxl__qmp_handler { static int qmp_send(libxl__qmp_handler *qmp, const char *cmd, libxl_key_value_list *args, -qmp_callback_t callback, void *opaque); +qmp_callback_t callback, void *opaque, +qmp_request_context *context); static const int QMP_SOCKET_CONNECT_TIMEOUT = 5; @@ -162,7 +168,7 @@ static int qmp_capabilities_callback(libxl__qmp_handler *qmp, static int enable_qmp_capabilities(libxl__qmp_handler *qmp) { return qmp_send(qmp, qmp_capabilities, NULL, -qmp_capabilities_callback, NULL); +qmp_capabilities_callback, NULL, NULL); } /* @@ -214,7 +220,10 @@ static void qmp_handle_error_response(libxl__qmp_handler *qmp, if (pp) { if (pp-callback) { -pp-callback(qmp, NULL, pp-opaque); +int rc = pp-callback(qmp, NULL, pp-opaque); +if (pp-context) { +pp-context-rc = rc; +} } if (pp-id == qmp-wait_for_id) { /* tell that the id have been processed */ @@ -241,16 +250,18 @@ static int qmp_handle_response(libxl__qmp_handler *qmp, switch (type) { case LIBXL__QMP_MESSAGE_TYPE_QMP: /* On the greeting message from the server, enable QMP capabilities */ -enable_qmp_capabilities(qmp); -break; +return enable_qmp_capabilities(qmp); case LIBXL__QMP_MESSAGE_TYPE_RETURN: { callback_id_pair *pp = qmp_get_callback_from_id(qmp, resp); if (pp) { if (pp-callback) { -pp-callback(qmp, +int rc = pp-callback(qmp, libxl__json_map_get(return, resp, JSON_ANY), pp-opaque); +if (pp-context) { +pp-context-rc = rc; +} } if (pp-id == qmp-wait_for_id) { /* tell that the id have been processed */ @@ -259,13 +270,13 @@ static int qmp_handle_response(libxl__qmp_handler *qmp, SIMPLEQ_REMOVE(qmp-callback_list, pp, callback_id_pair, next); free(pp); } -break; +return 0; } case LIBXL__QMP_MESSAGE_TYPE_ERROR: qmp_handle_error_response(qmp, resp); -break; +return -1; case LIBXL__QMP_MESSAGE_TYPE_EVENT: -break; +return 0; case LIBXL__QMP_MESSAGE_TYPE_INVALID: return -1; } @@ -358,6 +369,7 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp) char *incomplete = NULL; size_t incomplete_size = 0; +int rc = 0; do { fd_set rfds; @@ -415,7 +427,7 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp) o = libxl__json_parse(gc, s); if (o) { -qmp_handle_response(qmp, o); +rc = qmp_handle_response(qmp, o); libxl__json_object_free(gc, o); } else { LIBXL__LOG(qmp-ctx, LIBXL__LOG_ERROR, @@ -430,12 +442,13 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp) } while (s s_end); } while (s s_end); -return 1; +return rc; } static int qmp_send(libxl__qmp_handler *qmp, const char *cmd, libxl_key_value_list *args, -qmp_callback_t callback, void *opaque) +qmp_callback_t callback, void *opaque, +qmp_request_context *context) { yajl_gen_config conf = { 0, NULL }; const unsigned char *buf; @@ -477,6 +490,7 @@ static int qmp_send(libxl__qmp_handler *qmp, elm-id = qmp-last_id_used; elm-callback = callback; elm-opaque = opaque; +elm-context = context; SIMPLEQ_INSERT_TAIL(qmp-callback_list, elm, next); LIBXL__LOG(qmp-ctx, LIBXL__LOG_DEBUG, next qmp command: '%s', buf); @@ -505,8 +519,9 @@
[Qemu-devel] [Bug 884401] Re: PCI Passthrough for Digium TCE400P Codec Card Not working
Here is what my grub.conf looks like (see the addition of the intel_iommu=on: title CentOS Linux (2.6.32-71.29.1.el6.x86_64) root (hd0,0) kernel /vmlinuz-2.6.32-71.29.1.el6.x86_64 ro root=/dev/mapper/vg_twins-lv_root rd_LVM_LV=vg_twins/lv_root rd_LVM_LV=vg_twins/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=128M rhgb quiet intel_iommu=on initrd /initramfs-2.6.32-71.29.1.el6.x86_64.img -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/884401 Title: PCI Passthrough for Digium TCE400P Codec Card Not working Status in QEMU: New Bug description: trying to use a Digium TCE400P Codec card on a Virtual instance using the following information: lspci enter 02:08.0 Ethernet controller: Digium, Inc. Wildcard TCE400P transcoder base card (rev 11) lspci -n enter 02:08.0 0200: d161:8004 (rev 11) virsh nodedev-list | grep pci pci__02_08_0 printf %x 02 2 printf %x 08 8 printf %x 0 0 bus='0x02' slot='0x08' function='0x0' # virsh edit vmanager hostdev mode='subsystem' type='pci' managed='yes' source address domain='0x' bus='0x02' slot='0x08' function='0x0'/ /source /hostdev I have SELINUX disabled at this time. virsh start vmanager I get the following error message: [root@twins qemu]# virsh start vmanager error: Failed to start domain vmanager error: internal error Process exited while reading console log output: char device redirected to /dev/pts/2 Unable to assign device: PCI region 1 at address 0xdf1fe000 has size 0x400, which is not a multiple of 4K qemu-kvm: -device pci-assign,host=02:08.0,id=hostdev0,configfd=23,bus=pci.0,addr=0x6: Device 'pci-assign' could not be initialized Version Numbers: [root@twins qemu]# yum list | grep qemu gpxe-roms-qemu.noarch 0.9.7-6.3.el6_0.1 @updates qemu-img.x86_642:0.12.1.2-2.113.el6_0.8 @updates qemu-kvm.x86_642:0.12.1.2-2.113.el6_0.8 @updates qemu-kvm-tools.x86_64 2:0.12.1.2-2.113.el6_0.8 updates To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/884401/+subscriptions
Re: [Qemu-devel] [PATCH 1/2] Allow 1366x768 as a valid VGA resolution
On 11/01/11 14:39, John Baboval wrote: I don't know of any reason for it. I'd guess it is alignment, probably not important for all color depts. Maybe it is a good idea to do all sanity checks in the VBE_DISPI_INDEX_ENABLE branch where the actual mode switch happens. Then you already know xres, yres and depth when applying the checks. You can calculate the scanline length, then check the scanline alignment instead of being overly strict on xres in high color modes to satisfy alignment requirements in low color modes. You can also simply calculate how much memory the video mode needs and check that against the configured video ram instead of pulling xres and yres limits out of thin air. cheers, Gerd
[Qemu-devel] [PATCH v4 3/4] Add cap reduction support to enable use as SUID
The ideal way to use qemu-bridge-helper is to give it an fscap of using: setcap cap_net_admin=ep qemu-bridge-helper Unfortunately, most distros still do not have a mechanism to package files with fscaps applied. This means they'll have to SUID the qemu-bridge-helper binary. To improve security, use libcap to reduce our capability set to just cap_net_admin, then reduce privileges down to the calling user. This is hopefully close to equivalent to fscap support from a security perspective. Signed-off-by: Anthony Liguori aligu...@us.ibm.com Signed-off-by: Richa Marwaha rmar...@linux.vnet.ibm.com Signed-off-by: Corey Bryant cor...@linux.vnet.ibm.com --- configure| 34 ++ qemu-bridge-helper.c | 36 2 files changed, 70 insertions(+), 0 deletions(-) diff --git a/configure b/configure index 94c89a7..4e49b4b 100755 --- a/configure +++ b/configure @@ -128,6 +128,7 @@ vnc_thread=no xen= xen_ctrl_version= linux_aio= +cap= attr= xfs= @@ -654,6 +655,10 @@ for opt do ;; --enable-kvm) kvm=yes ;; + --disable-cap) cap=no + ;; + --enable-cap) cap=yes + ;; --disable-spice) spice=no ;; --enable-spice) spice=yes @@ -1037,6 +1042,8 @@ echo --disable-vdedisable support for vde network echo --enable-vde enable support for vde network echo --disable-linux-aio disable Linux AIO support echo --enable-linux-aio enable Linux AIO support +echo --disable-capdisable libcap-ng support +echo --enable-cap enable libcap-ng support echo --disable-attr disables attr and xattr support echo --enable-attrenable attr and xattr support echo --disable-blobs disable installing provided firmware blobs @@ -1645,6 +1652,29 @@ EOF fi ## +# libcap-ng library probe +if test $cap != no ; then + cap_libs=-lcap-ng + cat $TMPC EOF +#include cap-ng.h +int main(void) +{ +capng_capability_to_name(CAPNG_EFFECTIVE); +return 0; +} +EOF + if compile_prog $cap_libs ; then +cap=yes +libs_tools=$cap_libs $libs_tools + else +if test $cap = yes ; then + feature_not_found cap +fi +cap=no + fi +fi + +## # Sound support libraries probe audio_drv_probe() @@ -2761,6 +2791,7 @@ echo fdatasync $fdatasync echo madvise $madvise echo posix_madvise $posix_madvise echo uuid support $uuid +echo libcap-ng support $cap echo vhost-net support $vhost_net echo Trace backend $trace_backend echo Trace output file $trace_file-pid @@ -2873,6 +2904,9 @@ fi if test $vde = yes ; then echo CONFIG_VDE=y $config_host_mak fi +if test $cap = yes ; then + echo CONFIG_LIBCAP=y $config_host_mak +fi for card in $audio_card_list; do def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'` echo $def=y $config_host_mak diff --git a/qemu-bridge-helper.c b/qemu-bridge-helper.c index b5898a5..24f7460 100644 --- a/qemu-bridge-helper.c +++ b/qemu-bridge-helper.c @@ -37,6 +37,10 @@ #include net/tap-linux.h +#ifdef CONFIG_LIBCAP +#include cap-ng.h +#endif + #define DEFAULT_ACL_FILE CONFIG_QEMU_CONFDIR /bridge.conf enum { @@ -190,6 +194,27 @@ static int send_fd(int c, int fd) return sendmsg(c, msg, 0); } +#ifdef CONFIG_LIBCAP +static int drop_privileges(void) +{ +/* clear all capabilities */ +capng_clear(CAPNG_SELECT_BOTH); + +if (capng_update(CAPNG_ADD, CAPNG_EFFECTIVE | CAPNG_PERMITTED, + CAP_NET_ADMIN) 0) { +return -1; +} + +/* change to calling user's real uid and gid, retaining supplemental + * groups and CAP_NET_ADMIN */ +if (capng_change_id(getuid(), getgid(), CAPNG_CLEAR_BOUNDING)) { +return -1; +} + +return 0; +} +#endif + int main(int argc, char **argv) { struct ifreq ifr; @@ -204,6 +229,17 @@ int main(int argc, char **argv) int access_allowed, access_denied; int ret = EXIT_SUCCESS; +#ifdef CONFIG_LIBCAP +/* if we're run from an suid binary, immediately drop privileges preserving + * cap_net_admin */ +if (geteuid() == 0 getuid() != geteuid()) { +if (drop_privileges() == -1) { +fprintf(stderr, failed to drop privileges\n); +return 1; +} +} +#endif + /* parse arguments */ if (argc 3 || argc 4) { fprintf(stderr, Usage: %s [--use-vnet] BRIDGE FD\n, argv[0]); -- 1.7.3.4