Re: [Qemu-devel] [PATCH v2 15/19] dev-wacom: convert init to realize
static const VMStateDescription vmstate_usb_wacom = { @@ -357,7 +356,7 @@ static void usb_wacom_class_init(ObjectClass *klass, void *data) uc-product_desc = QEMU PenPartner Tablet; uc-usb_desc = desc_wacom; -uc-init = usb_wacom_initfn; +uc-realize = usb_wacom_realize; uc-handle_reset = usb_wacom_handle_reset; uc-handle_control = usb_wacom_handle_control; uc-handle_data= usb_wacom_handle_data; The new line isn't aligned with the others (here and in lots of other patches too). cheers, Gerd
Re: [Qemu-devel] [PATCH v2 15/19] dev-wacom: convert init to realize
Hi, From: Gerd Hoffmann [mailto:kra...@redhat.com] Sent: Friday, September 19, 2014 2:02 PM Subject: Re: [PATCH v2 15/19] dev-wacom: convert init to realize static const VMStateDescription vmstate_usb_wacom = { @@ -357,7 +356,7 @@ static void usb_wacom_class_init(ObjectClass *klass, void *data) uc-product_desc = QEMU PenPartner Tablet; uc-usb_desc = desc_wacom; -uc-init = usb_wacom_initfn; +uc-realize = usb_wacom_realize; uc-handle_reset = usb_wacom_handle_reset; uc-handle_control = usb_wacom_handle_control; uc-handle_data= usb_wacom_handle_data; The new line isn't aligned with the others (here and in lots of other patches too). OK. I will check and fix them shortly. Thanks! Best regards, -Gonglei cheers, Gerd
Re: [Qemu-devel] [PATCH v2 00/19] usb: convert device init to realize
On Do, 2014-09-18 at 20:47 +0800, arei.gong...@huawei.com wrote: From: Gonglei arei.gong...@huawei.com DeviceClass-init is the old interface, let's convert usb devices to the new realize API. In this way, all the implementations now use error_setg instead of qerror_report/error_report for reporting error. Looks good overall. One minor style nit, and there is the usb-serial issue pointed out by paolo, I'd like to see them handled. I don't care much whenever you do than with a v3 or 2-3 incremental patches to this one. cheers, Gerd
Re: [Qemu-devel] [PATCH] ohci: Convert fprint/DPRINTF/print to traces
On Fr, 2014-09-19 at 13:57 +1000, Alexey Kardashevskiy wrote: On 09/12/2014 06:55 PM, Alexey Kardashevskiy wrote: This converts many kinds of debug prints to traces. This implements packets logging to avoid unnecessary calculations if usb_ohci_td_pkt_short/usb_ohci_td_pkt_long is not enabled. This makes OHCI errors (such as DMA error) invisible by default. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- First I wanted to hide DMA error and OHCI die but then decided do to some housecleaning + community work :) I could have chosen wrong names for some traces, please comment. Thanks! Ping. Too much? Too bad? :) Too much email in my inbox. Added to usb queue now. thanks, Gerd
Re: [Qemu-devel] [PATCH v2] qemu-char: Do not disconnect when there's data for reading
Zifei Tong zifeit...@gmail.com writes: Hi Markus, On Thu, Sep 18, 2014 at 8:11 PM, Markus Armbruster arm...@redhat.com wrote: Zifei Tong zifeit...@gmail.com writes: After commit 812c1057f6175ac9a9829fa2920a2b5783814193 (Handle G_IO_HUP in tcp_chr_read for tcp chardev), connections are disconnected when in G_IO_HUP condition. However, it's possible that there is still data for reading in the channel. In that case, the remaining data is not handled. I saw a related bug when running socat in write-only mode, after $ echo quit | socat -u - UNIX-CONNECT:qemu-monitor the monitor won't not run the 'quit' command. Instead of GIOCondition, this patch uses the return value of tcp_chr_recv() to check the state of connection as suggested by Kirill. [...] @@ -2705,7 +2699,7 @@ static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque) if (len s-max_size) len = s-max_size; size = tcp_chr_recv(chr, (void *)buf, len); -if (size == 0) { +if (size == 0 || (size 0 !(errno == EAGAIN || errno == EINTR))) { /* connection closed */ tcp_chr_disconnect(chr); } else if (size 0) { What about EWOULDBLOCK? I thought EAGAIN and EWOULDBLOCK was the same thing, until Google told me it's not the case on some platforms like HP-UX, AIX and Tru64. Shall we add one more check to support these old platforms? Yes, please! [...]
Re: [Qemu-devel] [PATCH v2 00/19] usb: convert device init to realize
From: Gerd Hoffmann [mailto:kra...@redhat.com] Sent: Friday, September 19, 2014 2:06 PM To: Gonglei (Arei) Subject: Re: [PATCH v2 00/19] usb: convert device init to realize On Do, 2014-09-18 at 20:47 +0800, arei.gong...@huawei.com wrote: From: Gonglei arei.gong...@huawei.com DeviceClass-init is the old interface, let's convert usb devices to the new realize API. In this way, all the implementations now use error_setg instead of qerror_report/error_report for reporting error. Looks good overall. One minor style nit, and there is the usb-serial issue pointed out by paolo, I'd like to see them handled. I don't care much whenever you do than with a v3 or 2-3 incremental patches to this one. Got it. Thanks. :) Best regards, -Gonglei
[Qemu-devel] [PATCH v6 1/2] dump: let dump_error return error info to caller
The second parameter of dump_error is unused, but one purpose of using this function is to report the error info. Use error_set to return the error info to the caller. Signed-off-by: zhanghailiang zhang.zhanghaili...@huawei.com --- dump.c | 165 - 1 file changed, 82 insertions(+), 83 deletions(-) diff --git a/dump.c b/dump.c index 71d3e94..07d2300 100644 --- a/dump.c +++ b/dump.c @@ -81,9 +81,10 @@ static int dump_cleanup(DumpState *s) return 0; } -static void dump_error(DumpState *s, const char *reason) +static void dump_error(DumpState *s, const char *reason, Error **errp) { dump_cleanup(s); +error_setg(errp, %s, reason); } static int fd_write_vmcore(const void *buf, size_t size, void *opaque) @@ -99,7 +100,7 @@ static int fd_write_vmcore(const void *buf, size_t size, void *opaque) return 0; } -static int write_elf64_header(DumpState *s) +static int write_elf64_header(DumpState *s, Error **errp) { Elf64_Ehdr elf_header; int ret; @@ -126,14 +127,14 @@ static int write_elf64_header(DumpState *s) ret = fd_write_vmcore(elf_header, sizeof(elf_header), s); if (ret 0) { -dump_error(s, dump: failed to write elf header.\n); +dump_error(s, dump: failed to write elf header, errp); return -1; } return 0; } -static int write_elf32_header(DumpState *s) +static int write_elf32_header(DumpState *s, Error **errp) { Elf32_Ehdr elf_header; int ret; @@ -160,7 +161,7 @@ static int write_elf32_header(DumpState *s) ret = fd_write_vmcore(elf_header, sizeof(elf_header), s); if (ret 0) { -dump_error(s, dump: failed to write elf header.\n); +dump_error(s, dump: failed to write elf header, errp); return -1; } @@ -169,7 +170,7 @@ static int write_elf32_header(DumpState *s) static int write_elf64_load(DumpState *s, MemoryMapping *memory_mapping, int phdr_index, hwaddr offset, -hwaddr filesz) +hwaddr filesz, Error **errp) { Elf64_Phdr phdr; int ret; @@ -186,7 +187,7 @@ static int write_elf64_load(DumpState *s, MemoryMapping *memory_mapping, ret = fd_write_vmcore(phdr, sizeof(Elf64_Phdr), s); if (ret 0) { -dump_error(s, dump: failed to write program header table.\n); +dump_error(s, dump: failed to write program header table, errp); return -1; } @@ -195,7 +196,7 @@ static int write_elf64_load(DumpState *s, MemoryMapping *memory_mapping, static int write_elf32_load(DumpState *s, MemoryMapping *memory_mapping, int phdr_index, hwaddr offset, -hwaddr filesz) +hwaddr filesz, Error **errp) { Elf32_Phdr phdr; int ret; @@ -212,14 +213,14 @@ static int write_elf32_load(DumpState *s, MemoryMapping *memory_mapping, ret = fd_write_vmcore(phdr, sizeof(Elf32_Phdr), s); if (ret 0) { -dump_error(s, dump: failed to write program header table.\n); +dump_error(s, dump: failed to write program header table, errp); return -1; } return 0; } -static int write_elf64_note(DumpState *s) +static int write_elf64_note(DumpState *s, Error **errp) { Elf64_Phdr phdr; hwaddr begin = s-memory_offset - s-note_size; @@ -235,7 +236,7 @@ static int write_elf64_note(DumpState *s) ret = fd_write_vmcore(phdr, sizeof(Elf64_Phdr), s); if (ret 0) { -dump_error(s, dump: failed to write program header table.\n); +dump_error(s, dump: failed to write program header table, errp); return -1; } @@ -247,7 +248,8 @@ static inline int cpu_index(CPUState *cpu) return cpu-cpu_index + 1; } -static int write_elf64_notes(WriteCoreDumpFunction f, DumpState *s) +static int write_elf64_notes(WriteCoreDumpFunction f, DumpState *s, + Error **errp) { CPUState *cpu; int ret; @@ -257,7 +259,7 @@ static int write_elf64_notes(WriteCoreDumpFunction f, DumpState *s) id = cpu_index(cpu); ret = cpu_write_elf64_note(f, cpu, id, s); if (ret 0) { -dump_error(s, dump: failed to write elf notes.\n); +dump_error(s, dump: failed to write elf notes, errp); return -1; } } @@ -265,7 +267,7 @@ static int write_elf64_notes(WriteCoreDumpFunction f, DumpState *s) CPU_FOREACH(cpu) { ret = cpu_write_elf64_qemunote(f, cpu, s); if (ret 0) { -dump_error(s, dump: failed to write CPU status.\n); +dump_error(s, dump: failed to write CPU status, errp); return -1; } } @@ -273,7 +275,7 @@ static int write_elf64_notes(WriteCoreDumpFunction f, DumpState *s) return 0; } -static int write_elf32_note(DumpState *s) +static int write_elf32_note(DumpState *s, Error
[Qemu-devel] [PATCH v6 2/2] dump: Don't return error code when return an Error object
Functions shouldn't return an error code and an Error object at the same time. Turn all these functions that returning Error object to void. We also judge if a function success or fail by reference to the local_err. Signed-off-by: zhanghailiang zhang.zhanghaili...@huawei.com --- dump.c | 313 +++-- 1 file changed, 148 insertions(+), 165 deletions(-) diff --git a/dump.c b/dump.c index 07d2300..a6188b3 100644 --- a/dump.c +++ b/dump.c @@ -100,7 +100,7 @@ static int fd_write_vmcore(const void *buf, size_t size, void *opaque) return 0; } -static int write_elf64_header(DumpState *s, Error **errp) +static void write_elf64_header(DumpState *s, Error **errp) { Elf64_Ehdr elf_header; int ret; @@ -128,13 +128,10 @@ static int write_elf64_header(DumpState *s, Error **errp) ret = fd_write_vmcore(elf_header, sizeof(elf_header), s); if (ret 0) { dump_error(s, dump: failed to write elf header, errp); -return -1; } - -return 0; } -static int write_elf32_header(DumpState *s, Error **errp) +static void write_elf32_header(DumpState *s, Error **errp) { Elf32_Ehdr elf_header; int ret; @@ -162,13 +159,10 @@ static int write_elf32_header(DumpState *s, Error **errp) ret = fd_write_vmcore(elf_header, sizeof(elf_header), s); if (ret 0) { dump_error(s, dump: failed to write elf header, errp); -return -1; } - -return 0; } -static int write_elf64_load(DumpState *s, MemoryMapping *memory_mapping, +static void write_elf64_load(DumpState *s, MemoryMapping *memory_mapping, int phdr_index, hwaddr offset, hwaddr filesz, Error **errp) { @@ -188,15 +182,12 @@ static int write_elf64_load(DumpState *s, MemoryMapping *memory_mapping, ret = fd_write_vmcore(phdr, sizeof(Elf64_Phdr), s); if (ret 0) { dump_error(s, dump: failed to write program header table, errp); -return -1; } - -return 0; } -static int write_elf32_load(DumpState *s, MemoryMapping *memory_mapping, -int phdr_index, hwaddr offset, -hwaddr filesz, Error **errp) +static void write_elf32_load(DumpState *s, MemoryMapping *memory_mapping, + int phdr_index, hwaddr offset, + hwaddr filesz, Error **errp) { Elf32_Phdr phdr; int ret; @@ -214,13 +205,10 @@ static int write_elf32_load(DumpState *s, MemoryMapping *memory_mapping, ret = fd_write_vmcore(phdr, sizeof(Elf32_Phdr), s); if (ret 0) { dump_error(s, dump: failed to write program header table, errp); -return -1; } - -return 0; } -static int write_elf64_note(DumpState *s, Error **errp) +static void write_elf64_note(DumpState *s, Error **errp) { Elf64_Phdr phdr; hwaddr begin = s-memory_offset - s-note_size; @@ -237,10 +225,7 @@ static int write_elf64_note(DumpState *s, Error **errp) ret = fd_write_vmcore(phdr, sizeof(Elf64_Phdr), s); if (ret 0) { dump_error(s, dump: failed to write program header table, errp); -return -1; } - -return 0; } static inline int cpu_index(CPUState *cpu) @@ -248,8 +233,8 @@ static inline int cpu_index(CPUState *cpu) return cpu-cpu_index + 1; } -static int write_elf64_notes(WriteCoreDumpFunction f, DumpState *s, - Error **errp) +static void write_elf64_notes(WriteCoreDumpFunction f, DumpState *s, + Error **errp) { CPUState *cpu; int ret; @@ -260,7 +245,7 @@ static int write_elf64_notes(WriteCoreDumpFunction f, DumpState *s, ret = cpu_write_elf64_note(f, cpu, id, s); if (ret 0) { dump_error(s, dump: failed to write elf notes, errp); -return -1; +return; } } @@ -268,14 +253,12 @@ static int write_elf64_notes(WriteCoreDumpFunction f, DumpState *s, ret = cpu_write_elf64_qemunote(f, cpu, s); if (ret 0) { dump_error(s, dump: failed to write CPU status, errp); -return -1; +return; } } - -return 0; } -static int write_elf32_note(DumpState *s, Error **errp) +static void write_elf32_note(DumpState *s, Error **errp) { hwaddr begin = s-memory_offset - s-note_size; Elf32_Phdr phdr; @@ -292,14 +275,11 @@ static int write_elf32_note(DumpState *s, Error **errp) ret = fd_write_vmcore(phdr, sizeof(Elf32_Phdr), s); if (ret 0) { dump_error(s, dump: failed to write program header table, errp); -return -1; } - -return 0; } -static int write_elf32_notes(WriteCoreDumpFunction f, DumpState *s, - Error **errp) +static void write_elf32_notes(WriteCoreDumpFunction f, DumpState *s, + Error **errp) { CPUState *cpu; int
[Qemu-devel] [PATCH v6 0/2] dump: let dump_error return error reason to caller
Hi, In original code, Function dump_error ignores its second parameter which contains error reason, it is better to return the error message to the caller. Here we use error_setg to return the error info to caller. And at the same time, we turn functions like write_elf64_note() to void, Because functions shouldn't return an error code _and_ an Error object. After this modification the code will be more clean. v5 - v6 - Don't check *errp directly, if errp is NULL, there will be an error, Instead, check a local variable *local_err (Markus Armbruster) v4 - v5: - Turn functions like write_elf64_note() to void (Luiz Capitulino) v3 - v4: - Adjust the errp argument to the end - Remove trailing '.' in error messages v2 - v3: - Drop the '\n' in the message when call dump_error(Eric Blake) v1 - v2: - Return the error reason to the caller (Luiz Capitulino) zhanghailiang (2): dump: let dump_error return error info to caller dump: Don't return error code when return an Error object dump.c | 382 +++-- 1 file changed, 182 insertions(+), 200 deletions(-) -- 1.7.12.4
Re: [Qemu-devel] [PATCH 0/2] pflash (UEFI varstore) migration shortcut for libvirt
On 08/25/2014 08:33 PM, Paolo Bonzini wrote: Il 23/08/2014 12:19, Laszlo Ersek ha scritto: Libvirt is growing support for x86_64 OVMF guests: http://www.redhat.com/archives/libvir-list/2014-August/msg01045.html An important feature of such guests is the persistent store for non-volatile UEFI variables. This is implemented with if=pflash drives. The referenced libvirt patchset sets up the varstore files for single-host use. Wrt. migration, two choices have been considered: (a) full-blown live storage migration for the drives backing pflash devices, (b) vs. a shortcut that exploits the special nature of pflash drives (namely, their minuscule size, and a RAMBlock that keeps the full contents of each pflash drive visible to the guest, and is up-to-date, at all times.) Patch 1/2 is a trivial cleanup (some DPRINTF() calls in pflash_cfi01 have bit-rotted). Patch 2/2 seeks to implement choice (b), which is what the libvirt patchset relies on for migration. Thanks, Laszlo Laszlo Ersek (2): pflash_cfi01: fixup stale DPRINTF() calls pflash_cfi01: write flash contents to bdrv on incoming migration hw/block/pflash_cfi01.c | 18 -- 1 file changed, 16 insertions(+), 2 deletions(-) Reviewed-by: Paolo Bonzini pbonz...@redhat.com Alexey/David, I think hw/nvram/spapr_nvram.c should do the same. It doesn't have a vmstate, but you can probably use qemu_add_vm_change_state_handler to the same effect. I am not sure I understood the proposal correctly. Right now we use NVRAM on sPAPR as: -drive id=id3,if=none,file=qemu_nvram.img -global spapr-nvram.drive=id3 So the NVRAM file is BlockDriverState and HMP's migrate -b copies the content just fine. What is missing here? Thanks. -- Alexey
[Qemu-devel] [PATCH v3 00/19] usb: convert device init to realize
From: Gonglei arei.gong...@huawei.com DeviceClass-init is the old interface, let's convert usb devices to the new realize API. In this way, all the implementations now use error_setg instead of qerror_report/error_report for reporting error. Note: Next, I will post a incremental patch series fixing usb-serial issue. :) v3 - v2: - fix minor style align issues (Gerd) v2 - v1: - fix PATCH 2, using qerror_report_err print error messages when attach fails (Paolo) - using errp instead of qerror_report_err introduced by fix 1 in PATCH 12 (Paolo) - fix missing return in PATCH 14 (Paolo) - add 'Reviewed-by' tag for other patches Thanks a lot for reviewing! Gonglei (19): usb-storage: fix possible memory leak and missing error message usb-bus: convert USBDeviceClass init to realize usb-net: convert init to realize libusb: convert init to realize libusb: using error_report instead of fprintf usb-hub: convert init to realize dev-storage: convert init to realize dev-storage: usring error_report instead of fprintf/printf dev-uas: convert init to realize dev-uas: using error_report instead of fprintf dev-bluetooth: convert init to realize dev-serial: convert init to realize usb-ccid: convert init to realize dev-hid: convert init to realize dev-wacom: convert init to realize usb-audio: convert init to realize usb-redir: convert init to realize usb-mtp: convert init to realize usb-bus: remove init from USBDeviceClass struct hw/usb/bus.c | 79 ++- hw/usb/dev-audio.c| 5 ++- hw/usb/dev-bluetooth.c| 6 ++-- hw/usb/dev-hid.c | 27 +++ hw/usb/dev-hub.c | 9 +++-- hw/usb/dev-mtp.c | 5 ++- hw/usb/dev-network.c | 9 +++-- hw/usb/dev-serial.c | 22 +++- hw/usb/dev-smartcard-reader.c | 5 ++- hw/usb/dev-storage.c | 42 --- hw/usb/dev-uas.c | 17 +- hw/usb/dev-wacom.c| 5 ++- hw/usb/host-libusb.c | 33 +- hw/usb/redirect.c | 21 +++- include/hw/usb.h | 10 -- 15 files changed, 150 insertions(+), 145 deletions(-) -- 1.7.12.4
[Qemu-devel] [PATCH v3 05/19] libusb: using error_report instead of fprintf
From: Gonglei arei.gong...@huawei.com Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/host-libusb.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index dfb1750..45b74e5 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -275,7 +275,7 @@ static void usb_host_libusb_error(const char *func, int rc) } else { errname = ?; } -fprintf(stderr, %s: %d [%s]\n, func, rc, errname); +error_report(%s: %d [%s], func, rc, errname); } /* */ @@ -1376,14 +1376,13 @@ static int usb_host_alloc_streams(USBDevice *udev, USBEndpoint **eps, if (rc 0) { usb_host_libusb_error(libusb_alloc_streams, rc); } else if (rc != streams) { -fprintf(stderr, -libusb_alloc_streams: got less streams then requested %d %d\n, -rc, streams); +error_report(libusb_alloc_streams: got less streams + then requested %d %d, rc, streams); } return (rc == streams) ? 0 : -1; #else -fprintf(stderr, libusb_alloc_streams: error not implemented\n); +error_report(libusb_alloc_streams: error not implemented); return -1; #endif } -- 1.7.12.4
[Qemu-devel] [PATCH v3 08/19] dev-storage: usring error_report instead of fprintf/printf
From: Gonglei arei.gong...@huawei.com Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/dev-storage.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 182dd5a..a5e9d4a 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -409,19 +409,19 @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p) switch (s-mode) { case USB_MSDM_CBW: if (p-iov.size != 31) { -fprintf(stderr, usb-msd: Bad CBW size); +error_report(usb-msd: Bad CBW size); goto fail; } usb_packet_copy(p, cbw, 31); if (le32_to_cpu(cbw.sig) != 0x43425355) { -fprintf(stderr, usb-msd: Bad signature %08x\n, -le32_to_cpu(cbw.sig)); +error_report(usb-msd: Bad signature %08x, + le32_to_cpu(cbw.sig)); goto fail; } DPRINTF(Command on LUN %d\n, cbw.lun); scsi_dev = scsi_device_find(s-bus, 0, 0, cbw.lun); if (scsi_dev == NULL) { -fprintf(stderr, usb-msd: Bad LUN %d\n, cbw.lun); +error_report(usb-msd: Bad LUN %d, cbw.lun); goto fail; } tag = le32_to_cpu(cbw.tag); @@ -680,13 +680,13 @@ static USBDevice *usb_msd_init(USBBus *bus, const char *filename) pstrcpy(fmt, len, p2); qemu_opt_set(opts, format, fmt); } else if (*filename != ':') { -printf(unrecognized USB mass-storage option %s\n, filename); +error_report(unrecognized USB mass-storage option %s, filename); return NULL; } filename = p1; } if (!*filename) { -printf(block device specification needed\n); +error_report(block device specification needed); return NULL; } qemu_opt_set(opts, file, filename); -- 1.7.12.4
[Qemu-devel] [PATCH v3 11/19] dev-bluetooth: convert init to realize
From: Gonglei arei.gong...@huawei.com Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/dev-bluetooth.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/usb/dev-bluetooth.c b/hw/usb/dev-bluetooth.c index a76e581..390d475 100644 --- a/hw/usb/dev-bluetooth.c +++ b/hw/usb/dev-bluetooth.c @@ -501,7 +501,7 @@ static void usb_bt_handle_destroy(USBDevice *dev) s-hci-acl_recv = NULL; } -static int usb_bt_initfn(USBDevice *dev) +static void usb_bt_realize(USBDevice *dev, Error **errp) { struct USBBtState *s = DO_UPCAST(struct USBBtState, dev, dev); @@ -516,8 +516,6 @@ static int usb_bt_initfn(USBDevice *dev) s-hci-acl_recv = usb_bt_out_hci_packet_acl; usb_bt_handle_reset(s-dev); s-intr = usb_ep_get(dev, USB_TOKEN_IN, USB_EVT_EP); - -return 0; } static USBDevice *usb_bt_init(USBBus *bus, const char *cmdline) @@ -560,7 +558,7 @@ static void usb_bt_class_initfn(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); -uc-init = usb_bt_initfn; +uc-realize= usb_bt_realize; uc-product_desc = QEMU BT dongle; uc-usb_desc = desc_bluetooth; uc-handle_reset = usb_bt_handle_reset; -- 1.7.12.4
[Qemu-devel] [PATCH v3 02/19] usb-bus: convert USBDeviceClass init to realize
From: Gonglei arei.gong...@huawei.com Add realize/unrealize in USBDeviceClass, which has errp as a parameter. So all the implementations now use error_setg instead of error_report for reporting error. Note: this patch still keep init in USBDeviceClass, and call kclass-init in usb_device_realize(), avoid breaking git bisect. After realize all usb devices, will be removed. Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/bus.c | 81 +++- hw/usb/dev-serial.c | 16 +-- hw/usb/dev-storage.c | 11 +-- hw/usb/host-libusb.c | 7 +++-- hw/usb/redirect.c| 6 +++- include/hw/usb.h | 10 +-- 6 files changed, 81 insertions(+), 50 deletions(-) diff --git a/hw/usb/bus.c b/hw/usb/bus.c index c7c4dad..12881cb 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -9,7 +9,7 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent); static char *usb_get_dev_path(DeviceState *dev); static char *usb_get_fw_dev_path(DeviceState *qdev); -static int usb_qdev_exit(DeviceState *qdev); +static void usb_qdev_unrealize(DeviceState *qdev, Error **errp); static Property usb_props[] = { DEFINE_PROP_STRING(port, USBDevice, port_path), @@ -107,13 +107,15 @@ USBBus *usb_bus_find(int busnr) return NULL; } -static int usb_device_init(USBDevice *dev) +static void usb_device_realize(USBDevice *dev, Error **errp) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); -if (klass-init) { -return klass-init(dev); + +if (klass-realize) { +klass-realize(dev, errp); +} else if (klass-init) { +klass-init(dev); } -return 0; } USBDevice *usb_device_find_device(USBDevice *dev, uint8_t addr) @@ -232,36 +234,41 @@ void usb_device_free_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps) } } -static int usb_qdev_init(DeviceState *qdev) +static void usb_qdev_realize(DeviceState *qdev, Error **errp) { USBDevice *dev = USB_DEVICE(qdev); -int rc; +Error *local_err = NULL; pstrcpy(dev-product_desc, sizeof(dev-product_desc), usb_device_get_product_desc(dev)); dev-auto_attach = 1; QLIST_INIT(dev-strings); usb_ep_init(dev); -rc = usb_claim_port(dev); -if (rc != 0) { -return rc; + +usb_claim_port(dev, local_err); +if (local_err) { +error_propagate(errp, local_err); +return; } -rc = usb_device_init(dev); -if (rc != 0) { + +usb_device_realize(dev, local_err); +if (local_err) { usb_release_port(dev); -return rc; +error_propagate(errp, local_err); +return; } + if (dev-auto_attach) { -rc = usb_device_attach(dev); -if (rc != 0) { -usb_qdev_exit(qdev); -return rc; +usb_device_attach(dev, local_err); +if (local_err) { +usb_qdev_unrealize(qdev, NULL); +error_propagate(errp, local_err); +return; } } -return 0; } -static int usb_qdev_exit(DeviceState *qdev) +static void usb_qdev_unrealize(DeviceState *qdev, Error **errp) { USBDevice *dev = USB_DEVICE(qdev); @@ -272,7 +279,6 @@ static int usb_qdev_exit(DeviceState *qdev) if (dev-port) { usb_release_port(dev); } -return 0; } typedef struct LegacyUSBFactory @@ -392,7 +398,7 @@ void usb_unregister_port(USBBus *bus, USBPort *port) bus-nfree--; } -int usb_claim_port(USBDevice *dev) +void usb_claim_port(USBDevice *dev, Error **errp) { USBBus *bus = usb_bus_from_device(dev); USBPort *port; @@ -406,9 +412,9 @@ int usb_claim_port(USBDevice *dev) } } if (port == NULL) { -error_report(Error: usb port %s (bus %s) not found (in use?), - dev-port_path, bus-qbus.name); -return -1; +error_setg(errp, Error: usb port %s (bus %s) not found (in use?), + dev-port_path, bus-qbus.name); +return; } } else { if (bus-nfree == 1 strcmp(object_get_typename(OBJECT(dev)), usb-hub) != 0) { @@ -416,9 +422,9 @@ int usb_claim_port(USBDevice *dev) usb_create_simple(bus, usb-hub); } if (bus-nfree == 0) { -error_report(Error: tried to attach usb device %s to a bus - with no free ports, dev-product_desc); -return -1; +error_setg(errp, Error: tried to attach usb device %s to a bus + with no free ports, dev-product_desc); +return; } port = QTAILQ_FIRST(bus-free); } @@ -432,7 +438,6 @@ int usb_claim_port(USBDevice *dev) QTAILQ_INSERT_TAIL(bus-used, port, next); bus-nused++; -return 0; } void usb_release_port(USBDevice *dev) @@ -475,7 +480,7 @@ static void usb_mask_to_str(char *dest, size_t size, } } -int usb_device_attach(USBDevice *dev)
[Qemu-devel] [PATCH v3 07/19] dev-storage: convert init to realize
From: Gonglei arei.gong...@huawei.com In this way, all the implementations now use error_setg instead of error_report for reporting error. Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/dev-storage.c | 21 - 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 06f63d1..182dd5a 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -595,7 +595,7 @@ static const struct SCSIBusInfo usb_msd_scsi_info_bot = { .load_request = usb_msd_load_request, }; -static int usb_msd_initfn_storage(USBDevice *dev) +static void usb_msd_realize_storage(USBDevice *dev, Error **errp) { MSDState *s = DO_UPCAST(MSDState, dev, dev); BlockDriverState *bs = s-conf.bs; @@ -603,8 +603,8 @@ static int usb_msd_initfn_storage(USBDevice *dev) Error *err = NULL; if (!bs) { -error_report(drive property not set); -return -1; +error_setg(errp, drive property not set); +return; } blkconf_serial(s-conf, dev-serial); @@ -629,9 +629,8 @@ static int usb_msd_initfn_storage(USBDevice *dev) s-conf.bootindex, dev-serial, err); if (!scsi_dev) { -error_report(%s, error_get_pretty(err)); -error_free(err); -return -1; +error_propagate(errp, err); +return; } s-bus.qbus.allow_hotplug = 0; usb_msd_handle_reset(dev); @@ -644,11 +643,9 @@ static int usb_msd_initfn_storage(USBDevice *dev) autostart = 0; } } - -return 0; } -static int usb_msd_initfn_bot(USBDevice *dev) +static void usb_msd_realize_bot(USBDevice *dev, Error **errp) { MSDState *s = DO_UPCAST(MSDState, dev, dev); @@ -658,8 +655,6 @@ static int usb_msd_initfn_bot(USBDevice *dev) usb_msd_scsi_info_bot, NULL); s-bus.qbus.allow_hotplug = 0; usb_msd_handle_reset(dev); - -return 0; } static USBDevice *usb_msd_init(USBBus *bus, const char *filename) @@ -765,7 +760,7 @@ static void usb_msd_class_initfn_storage(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); -uc-init = usb_msd_initfn_storage; +uc-realize = usb_msd_realize_storage; dc-props = msd_properties; usb_msd_class_initfn_common(klass); } @@ -774,7 +769,7 @@ static void usb_msd_class_initfn_bot(ObjectClass *klass, void *data) { USBDeviceClass *uc = USB_DEVICE_CLASS(klass); -uc-init = usb_msd_initfn_bot; +uc-realize = usb_msd_realize_bot; usb_msd_class_initfn_common(klass); } -- 1.7.12.4
[Qemu-devel] [PATCH v3 06/19] usb-hub: convert init to realize
From: Gonglei arei.gong...@huawei.com In this way, all the implementations now use error_setg instead of error_report for reporting error. Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/dev-hub.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c index 7492174..0482f58 100644 --- a/hw/usb/dev-hub.c +++ b/hw/usb/dev-hub.c @@ -511,15 +511,15 @@ static USBPortOps usb_hub_port_ops = { .complete = usb_hub_complete, }; -static int usb_hub_initfn(USBDevice *dev) +static void usb_hub_realize(USBDevice *dev, Error **errp) { USBHubState *s = DO_UPCAST(USBHubState, dev, dev); USBHubPort *port; int i; if (dev-port-hubcount == 5) { -error_report(usb hub chain too deep); -return -1; +error_setg(errp, usb hub chain too deep); +return; } usb_desc_create_serial(dev); @@ -533,7 +533,6 @@ static int usb_hub_initfn(USBDevice *dev) usb_port_location(port-port, dev-port, i+1); } usb_hub_handle_reset(dev); -return 0; } static const VMStateDescription vmstate_usb_hub_port = { @@ -564,7 +563,7 @@ static void usb_hub_class_initfn(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); -uc-init = usb_hub_initfn; +uc-realize= usb_hub_realize; uc-product_desc = QEMU USB Hub; uc-usb_desc = desc_hub; uc-find_device= usb_hub_find_device; -- 1.7.12.4
[Qemu-devel] [PATCH v3 09/19] dev-uas: convert init to realize
From: Gonglei arei.gong...@huawei.com Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/dev-uas.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index 9832385..a97a02f 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -892,7 +892,7 @@ static void usb_uas_handle_destroy(USBDevice *dev) qemu_bh_delete(uas-status_bh); } -static int usb_uas_init(USBDevice *dev) +static void usb_uas_realize(USBDevice *dev, Error **errp) { UASDevice *uas = DO_UPCAST(UASDevice, dev, dev); @@ -905,8 +905,6 @@ static int usb_uas_init(USBDevice *dev) scsi_bus_new(uas-bus, sizeof(uas-bus), DEVICE(dev), usb_uas_scsi_info, NULL); - -return 0; } static const VMStateDescription vmstate_usb_uas = { @@ -928,7 +926,7 @@ static void usb_uas_class_initfn(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); -uc-init = usb_uas_init; +uc-realize= usb_uas_realize; uc-product_desc = desc_strings[STR_PRODUCT]; uc-usb_desc = desc; uc-cancel_packet = usb_uas_cancel_io; -- 1.7.12.4
[Qemu-devel] [PATCH v3 10/19] dev-uas: using error_report instead of fprintf
From: Gonglei arei.gong...@huawei.com Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/dev-uas.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index a97a02f..04fc515 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -13,6 +13,7 @@ #include qemu/option.h #include qemu/config-file.h #include trace.h +#include qemu/error-report.h #include hw/usb.h #include hw/usb/desc.h @@ -648,7 +649,7 @@ static void usb_uas_handle_control(USBDevice *dev, USBPacket *p, if (ret = 0) { return; } -fprintf(stderr, %s: unhandled control request\n, __func__); +error_report(%s: unhandled control request, __func__); p-status = USB_RET_STALL; } @@ -814,8 +815,8 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p) usb_uas_task(uas, iu); break; default: -fprintf(stderr, %s: unknown command iu: id 0x%x\n, -__func__, iu.hdr.id); +error_report(%s: unknown command iu: id 0x%x, + __func__, iu.hdr.id); p-status = USB_RET_STALL; break; } @@ -861,7 +862,7 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p) p-status = USB_RET_ASYNC; break; } else { -fprintf(stderr, %s: no inflight request\n, __func__); +error_report(%s: no inflight request, __func__); p-status = USB_RET_STALL; break; } @@ -879,7 +880,7 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p) usb_uas_start_next_transfer(uas); break; default: -fprintf(stderr, %s: invalid endpoint %d\n, __func__, p-ep-nr); +error_report(%s: invalid endpoint %d, __func__, p-ep-nr); p-status = USB_RET_STALL; break; } -- 1.7.12.4
[Qemu-devel] [PATCH v3 03/19] usb-net: convert init to realize
From: Gonglei arei.gong...@huawei.com meanwhile, qerror_report_err() is a transitional interface to help with converting existing HMP commands to QMP. It should not be used elsewhere. Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/dev-network.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 518d536..23e3c45 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -27,7 +27,7 @@ #include hw/usb.h #include hw/usb/desc.h #include net/net.h -#include qapi/qmp/qerror.h +#include qemu/error-report.h #include qemu/queue.h #include qemu/config-file.h #include sysemu/sysemu.h @@ -1341,7 +1341,7 @@ static NetClientInfo net_usbnet_info = { .cleanup = usbnet_cleanup, }; -static int usb_net_initfn(USBDevice *dev) +static void usb_net_realize(USBDevice *dev, Error **errrp) { USBNetState *s = DO_UPCAST(USBNetState, dev, dev); @@ -1373,7 +1373,6 @@ static int usb_net_initfn(USBDevice *dev) usb_desc_set_string(dev, STRING_ETHADDR, s-usbstring_mac); add_boot_device_path(s-conf.bootindex, dev-qdev, /ethernet@0); -return 0; } static USBDevice *usb_net_init(USBBus *bus, const char *cmdline) @@ -1392,7 +1391,7 @@ static USBDevice *usb_net_init(USBBus *bus, const char *cmdline) idx = net_client_init(opts, 0, local_err); if (local_err) { -qerror_report_err(local_err); +error_report(%s, error_get_pretty(local_err)); error_free(local_err); return NULL; } @@ -1421,7 +1420,7 @@ static void usb_net_class_initfn(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); -uc-init = usb_net_initfn; +uc-realize= usb_net_realize; uc-product_desc = QEMU USB Network Interface; uc-usb_desc = desc_net; uc-handle_reset = usb_net_handle_reset; -- 1.7.12.4
[Qemu-devel] [PATCH v3 15/19] dev-wacom: convert init to realize
From: Gonglei arei.gong...@huawei.com Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/dev-wacom.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/usb/dev-wacom.c b/hw/usb/dev-wacom.c index 1b73fd0..844eafa 100644 --- a/hw/usb/dev-wacom.c +++ b/hw/usb/dev-wacom.c @@ -335,14 +335,13 @@ static void usb_wacom_handle_destroy(USBDevice *dev) } } -static int usb_wacom_initfn(USBDevice *dev) +static void usb_wacom_realize(USBDevice *dev, Error **errp) { USBWacomState *s = DO_UPCAST(USBWacomState, dev, dev); usb_desc_create_serial(dev); usb_desc_init(dev); s-intr = usb_ep_get(dev, USB_TOKEN_IN, 1); s-changed = 1; -return 0; } static const VMStateDescription vmstate_usb_wacom = { @@ -357,7 +356,7 @@ static void usb_wacom_class_init(ObjectClass *klass, void *data) uc-product_desc = QEMU PenPartner Tablet; uc-usb_desc = desc_wacom; -uc-init = usb_wacom_initfn; +uc-realize= usb_wacom_realize; uc-handle_reset = usb_wacom_handle_reset; uc-handle_control = usb_wacom_handle_control; uc-handle_data= usb_wacom_handle_data; -- 1.7.12.4
[Qemu-devel] [PATCH v3 01/19] usb-storage: fix possible memory leak and missing error message
From: Gonglei arei.gong...@huawei.com When scsi_bus_legacy_add_drive() return NULL, meanwhile err will be not NULL, which will casue memory leak and missing error message. Cc: Markus Armbruster arm...@redhat.com Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/dev-storage.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index ae4efcb..f731b0a 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -624,6 +624,8 @@ static int usb_msd_initfn_storage(USBDevice *dev) s-conf.bootindex, dev-serial, err); if (!scsi_dev) { +error_report(%s, error_get_pretty(err)); +error_free(err); return -1; } s-bus.qbus.allow_hotplug = 0; -- 1.7.12.4
[Qemu-devel] [PATCH v3 16/19] usb-audio: convert init to realize
From: Gonglei arei.gong...@huawei.com Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/dev-audio.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c index 7b9957b..67deffe 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -628,7 +628,7 @@ static void usb_audio_handle_destroy(USBDevice *dev) streambuf_fini(s-out.buf); } -static int usb_audio_initfn(USBDevice *dev) +static void usb_audio_realize(USBDevice *dev, Error **errp) { USBAudioState *s = DO_UPCAST(USBAudioState, dev, dev); @@ -651,7 +651,6 @@ static int usb_audio_initfn(USBDevice *dev) s, output_callback, s-out.as); AUD_set_volume_out(s-out.voice, s-out.mute, s-out.vol[0], s-out.vol[1]); AUD_set_active_out(s-out.voice, 0); -return 0; } static const VMStateDescription vmstate_usb_audio = { @@ -676,7 +675,7 @@ static void usb_audio_class_init(ObjectClass *klass, void *data) set_bit(DEVICE_CATEGORY_SOUND, dc-categories); k-product_desc = QEMU USB Audio Interface; k-usb_desc = desc_audio; -k-init = usb_audio_initfn; +k-realize= usb_audio_realize; k-handle_reset = usb_audio_handle_reset; k-handle_control = usb_audio_handle_control; k-handle_data= usb_audio_handle_data; -- 1.7.12.4
[Qemu-devel] [PATCH v3 04/19] libusb: convert init to realize
From: Gonglei arei.gong...@huawei.com In this way, all the implementations now use error_setg instead of error_report for reporting error. Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/host-libusb.c | 17 - 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 9f92705..dfb1750 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -951,21 +951,21 @@ static void usb_host_exit_notifier(struct Notifier *n, void *data) } } -static int usb_host_initfn(USBDevice *udev) +static void usb_host_realize(USBDevice *udev, Error **errp) { USBHostDevice *s = USB_HOST_DEVICE(udev); if (s-match.vendor_id 0x) { -error_report(vendorid out of range); -return -1; +error_setg(errp, vendorid out of range); +return; } if (s-match.product_id 0x) { -error_report(productid out of range); -return -1; +error_setg(errp, productid out of range); +return; } if (s-match.addr 127) { -error_report(hostaddr out of range); -return -1; +error_setg(errp, hostaddr out of range); +return; } loglevel = s-loglevel; @@ -980,7 +980,6 @@ static int usb_host_initfn(USBDevice *udev) QTAILQ_INSERT_TAIL(hostdevs, s, next); add_boot_device_path(s-bootindex, udev-qdev, NULL); usb_host_auto_check(NULL); -return 0; } static void usb_host_handle_destroy(USBDevice *udev) @@ -1480,7 +1479,7 @@ static void usb_host_class_initfn(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); -uc-init = usb_host_initfn; +uc-realize= usb_host_realize; uc-product_desc = USB Host Device; uc-cancel_packet = usb_host_cancel_packet; uc-handle_data= usb_host_handle_data; -- 1.7.12.4
[Qemu-devel] [PATCH v3 17/19] usb-redir: convert init to realize
From: Gonglei arei.gong...@huawei.com In this way, all the implementations now use error_setg instead of qerror_report for reporting error. Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/redirect.c | 15 +++ 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 95158b3..e2c9896 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1361,14 +1361,14 @@ static void usbredir_init_endpoints(USBRedirDevice *dev) } } -static int usbredir_initfn(USBDevice *udev) +static void usbredir_realize(USBDevice *udev, Error **errp) { USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, udev); int i; if (dev-cs == NULL) { -qerror_report(QERR_MISSING_PARAMETER, chardev); -return -1; +error_set(errp, QERR_MISSING_PARAMETER, chardev); +return; } if (dev-filter_str) { @@ -1376,9 +1376,9 @@ static int usbredir_initfn(USBDevice *udev) dev-filter_rules, dev-filter_rules_count); if (i) { -qerror_report(QERR_INVALID_PARAMETER_VALUE, filter, - a usb device filter string); -return -1; +error_set(errp, QERR_INVALID_PARAMETER_VALUE, filter, + a usb device filter string); +return; } } @@ -1402,7 +1402,6 @@ static int usbredir_initfn(USBDevice *udev) qemu_add_vm_change_state_handler(usbredir_vm_state_change, dev); add_boot_device_path(dev-bootindex, udev-qdev, NULL); -return 0; } static void usbredir_cleanup_device_queues(USBRedirDevice *dev) @@ -2481,7 +2480,7 @@ static void usbredir_class_initfn(ObjectClass *klass, void *data) USBDeviceClass *uc = USB_DEVICE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass); -uc-init = usbredir_initfn; +uc-realize= usbredir_realize; uc-product_desc = USB Redirection Device; uc-handle_destroy = usbredir_handle_destroy; uc-cancel_packet = usbredir_cancel_packet; -- 1.7.12.4
[Qemu-devel] [PATCH v3 13/19] usb-ccid: convert init to realize
From: Gonglei arei.gong...@huawei.com Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/dev-smartcard-reader.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 470e69f..d37ed02 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -1304,7 +1304,7 @@ static int ccid_card_init(DeviceState *qdev) return ret; } -static int ccid_initfn(USBDevice *dev) +static void ccid_realize(USBDevice *dev, Error **errp) { USBCCIDState *s = DO_UPCAST(USBCCIDState, dev, dev); @@ -1332,7 +1332,6 @@ static int ccid_initfn(USBDevice *dev) ccid_reset_parameters(s); ccid_reset(s); s-debug = parse_debug_env(QEMU_CCID_DEBUG, D_VERBOSE, s-debug); -return 0; } static int ccid_post_load(void *opaque, int version_id) @@ -1441,7 +1440,7 @@ static void ccid_class_initfn(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); -uc-init = ccid_initfn; +uc-realize= ccid_realize; uc-product_desc = QEMU USB CCID; uc-usb_desc = desc_ccid; uc-handle_reset = ccid_handle_reset; -- 1.7.12.4
[Qemu-devel] [PATCH v3 19/19] usb-bus: remove init from USBDeviceClass struct
From: Gonglei arei.gong...@huawei.com All usb-bus devices are realized by realize(), remove init callback function from USBDeviceClass struct. Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/bus.c | 2 -- include/hw/usb.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 12881cb..b375293 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -113,8 +113,6 @@ static void usb_device_realize(USBDevice *dev, Error **errp) if (klass-realize) { klass-realize(dev, errp); -} else if (klass-init) { -klass-init(dev); } } diff --git a/include/hw/usb.h b/include/hw/usb.h index 612f09f..8ffbba2 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -273,8 +273,6 @@ typedef void (*USBDeviceUnrealize)(USBDevice *dev, Error **errp); typedef struct USBDeviceClass { DeviceClass parent_class; -int (*init)(USBDevice *dev); - USBDeviceRealize realize; USBDeviceUnrealize unrealize; -- 1.7.12.4
[Qemu-devel] [PATCH v3 14/19] dev-hid: convert init to realize
From: Gonglei arei.gong...@huawei.com In this way, all the implementations now use error_setg instead of error_report for reporting error. Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/dev-hid.c | 27 +-- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c index 67a57f1..467ec86 100644 --- a/hw/usb/dev-hid.c +++ b/hw/usb/dev-hid.c @@ -566,7 +566,7 @@ static void usb_hid_handle_destroy(USBDevice *dev) hid_free(us-hid); } -static int usb_hid_initfn(USBDevice *dev, int kind) +static void usb_hid_initfn(USBDevice *dev, int kind) { USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev); @@ -579,10 +579,9 @@ static int usb_hid_initfn(USBDevice *dev, int kind) if (us-display us-hid.s) { qemu_input_handler_bind(us-hid.s, us-display, us-head, NULL); } -return 0; } -static int usb_tablet_initfn(USBDevice *dev) +static void usb_tablet_realize(USBDevice *dev, Error **errp) { USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev); @@ -594,22 +593,22 @@ static int usb_tablet_initfn(USBDevice *dev) dev-usb_desc = desc_tablet2; break; default: -error_report(Invalid usb version %d for usb-tabler (must be 1 or 2), - us-usb_version); -return -1; +error_setg(errp, Invalid usb version %d for usb-tablet + (must be 1 or 2), us-usb_version); +return; } -return usb_hid_initfn(dev, HID_TABLET); +usb_hid_initfn(dev, HID_TABLET); } -static int usb_mouse_initfn(USBDevice *dev) +static void usb_mouse_realize(USBDevice *dev, Error **errp) { -return usb_hid_initfn(dev, HID_MOUSE); +usb_hid_initfn(dev, HID_MOUSE); } -static int usb_keyboard_initfn(USBDevice *dev) +static void usb_keyboard_realize(USBDevice *dev, Error **errp) { -return usb_hid_initfn(dev, HID_KEYBOARD); +usb_hid_initfn(dev, HID_KEYBOARD); } static int usb_ptr_post_load(void *opaque, int version_id) @@ -669,7 +668,7 @@ static void usb_tablet_class_initfn(ObjectClass *klass, void *data) USBDeviceClass *uc = USB_DEVICE_CLASS(klass); usb_hid_class_initfn(klass, data); -uc-init = usb_tablet_initfn; +uc-realize= usb_tablet_realize; uc-product_desc = QEMU USB Tablet; dc-vmsd = vmstate_usb_ptr; dc-props = usb_tablet_properties; @@ -689,7 +688,7 @@ static void usb_mouse_class_initfn(ObjectClass *klass, void *data) USBDeviceClass *uc = USB_DEVICE_CLASS(klass); usb_hid_class_initfn(klass, data); -uc-init = usb_mouse_initfn; +uc-realize= usb_mouse_realize; uc-product_desc = QEMU USB Mouse; uc-usb_desc = desc_mouse; dc-vmsd = vmstate_usb_ptr; @@ -714,7 +713,7 @@ static void usb_keyboard_class_initfn(ObjectClass *klass, void *data) USBDeviceClass *uc = USB_DEVICE_CLASS(klass); usb_hid_class_initfn(klass, data); -uc-init = usb_keyboard_initfn; +uc-realize= usb_keyboard_realize; uc-product_desc = QEMU USB Keyboard; uc-usb_desc = desc_keyboard; dc-vmsd = vmstate_usb_kbd; -- 1.7.12.4
[Qemu-devel] [PATCH v3 18/19] usb-mtp: convert init to realize
From: Gonglei arei.gong...@huawei.com Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/dev-mtp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 0820046..108ece8 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -1060,7 +1060,7 @@ static void usb_mtp_handle_data(USBDevice *dev, USBPacket *p) } } -static int usb_mtp_initfn(USBDevice *dev) +static void usb_mtp_realize(USBDevice *dev, Error **errp) { MTPState *s = DO_UPCAST(MTPState, dev, dev); @@ -1075,7 +1075,6 @@ static int usb_mtp_initfn(USBDevice *dev) s-desc = g_strdup(none); } } -return 0; } static const VMStateDescription vmstate_usb_mtp = { @@ -1100,7 +1099,7 @@ static void usb_mtp_class_initfn(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); -uc-init = usb_mtp_initfn; +uc-realize= usb_mtp_realize; uc-product_desc = QEMU USB MTP; uc-usb_desc = desc; uc-cancel_packet = usb_mtp_cancel_packet; -- 1.7.12.4
[Qemu-devel] [PATCH v3 12/19] dev-serial: convert init to realize
From: Gonglei arei.gong...@huawei.com In this way, all the implementations now use error_setg instead of error_report for reporting error. Signed-off-by: Gonglei arei.gong...@huawei.com Reviewed-by: Paolo Bonzini pbonz...@redhat.com --- hw/usb/dev-serial.c | 18 ++ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index eb1b115..3784f4a 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -476,18 +476,17 @@ static void usb_serial_event(void *opaque, int event) } } -static int usb_serial_initfn(USBDevice *dev) +static void usb_serial_realize(USBDevice *dev, Error **errp) { USBSerialState *s = DO_UPCAST(USBSerialState, dev, dev); -Error *local_err = NULL; usb_desc_create_serial(dev); usb_desc_init(dev); dev-auto_attach = 0; if (!s-cs) { -error_report(Property chardev is required); -return -1; +error_setg(errp, Property chardev is required); +return; } qemu_chr_add_handlers(s-cs, usb_serial_can_read, usb_serial_read, @@ -495,13 +494,8 @@ static int usb_serial_initfn(USBDevice *dev) usb_serial_handle_reset(dev); if (s-cs-be_open !dev-attached) { -usb_device_attach(dev, local_err); -if (local_err) { -qerror_report_err(local_err); -error_free(local_err); -} +usb_device_attach(dev, errp); } -return 0; } static USBDevice *usb_serial_init(USBBus *bus, const char *filename) @@ -592,7 +586,7 @@ static void usb_serial_class_initfn(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); -uc-init = usb_serial_initfn; +uc-realize = usb_serial_realize; uc-product_desc = QEMU USB Serial; uc-usb_desc = desc_serial; uc-handle_reset = usb_serial_handle_reset; @@ -620,7 +614,7 @@ static void usb_braille_class_initfn(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); -uc-init = usb_serial_initfn; +uc-realize= usb_serial_realize; uc-product_desc = QEMU USB Braille; uc-usb_desc = desc_braille; uc-handle_reset = usb_serial_handle_reset; -- 1.7.12.4
Re: [Qemu-devel] [PATCH v2 00/19] usb: convert device init to realize
Paolo Bonzini pbonz...@redhat.com writes: Il 18/09/2014 19:15, Markus Armbruster ha scritto: Thanks for doing this work. If you can do a bit more of the same, here are a few more device model init() methods I'd love to have converted, because they use qerror_report_err(): hw/char/serial-pci.cserial_pci_init() multi_serial_pci_init() hw/i386/kvm/pci-assign.cassigned_initfn() Converting PCI is Gargantuan, but even something like patch 1 in this series would be nice to have. Converting all the PCI devices in one go is Gargantuan indeed. Could we enable incremental conversion?
[Qemu-devel] [PATCH v3] qemu-char: Do not disconnect when there's data for reading
After commit 812c1057f6175ac9a9829fa2920a2b5783814193 (Handle G_IO_HUP in tcp_chr_read for tcp chardev), connections are disconnected when in G_IO_HUP condition. However, it's possible that there is still data for reading in the channel. In that case, the remaining data is not handled. I saw a related bug when running socat in write-only mode, after $ echo quit | socat -u - UNIX-CONNECT:qemu-monitor the monitor won't not run the 'quit' command. Instead of GIOCondition, this patch uses the return value of tcp_chr_recv() to check the state of connection as suggested by Kirill. Cc: Kirill Batuzov batuz...@ispras.ru Cc: Nikolay Nikolaev n.nikol...@virtualopensystems.com Cc: Markus Armbruster arm...@redhat.com Cc: Anthony Liguori aligu...@amazon.com Signed-off-by: Zifei Tong zifeit...@gmail.com --- Changes in v3: handle EWOULDBLOCK, remove inaccurate comment qemu-char.c | 10 ++ 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 2a3cb9f..d1893a0 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2692,12 +2692,6 @@ static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque) uint8_t buf[READ_BUF_LEN]; int len, size; -if (cond G_IO_HUP) { -/* connection closed */ -tcp_chr_disconnect(chr); -return TRUE; -} - if (!s-connected || s-max_size = 0) { return TRUE; } @@ -2705,8 +2699,8 @@ static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque) if (len s-max_size) len = s-max_size; size = tcp_chr_recv(chr, (void *)buf, len); -if (size == 0) { -/* connection closed */ +if (size == 0 || +(size 0 !(errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR))) { tcp_chr_disconnect(chr); } else if (size 0) { if (s-do_telnetopt) -- 2.1.0
Re: [Qemu-devel] [PATCH v2] ivshmem: use error_report
On 09/19/2014 01:17 AM, Andrew Jones wrote: Replace all the fprintf(stderr, ...) calls with error_report. Also make sure exit() consistently uses the error code 1. A few calls used -1. Signed-off-by: Andrew Jones drjo...@redhat.com --- hw/misc/ivshmem.c | 39 +++ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index bf585b7691998..b3983296f58fa 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -300,8 +300,8 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier * chr = qemu_chr_open_eventfd(eventfd); if (chr == NULL) { -fprintf(stderr, creating eventfd for eventfd %d failed\n, eventfd); -exit(-1); +error_report(creating eventfd for eventfd %d failed, eventfd); +exit(1); } qemu_chr_fe_claim_no_fail(chr); @@ -328,15 +328,14 @@ static int check_shm_size(IVShmemState *s, int fd) { struct stat buf; if (fstat(fd, buf) 0) { -fprintf(stderr, ivshmem: exiting: fstat on fd %d failed: %s\n, +error_report(exiting: fstat on fd %d failed: %s, fd, strerror(errno)); return -1; } if (s-ivshmem_size buf.st_size) { -fprintf(stderr, -IVSHMEM ERROR: Requested memory size greater - than shared object size (% PRIu64 % PRIu64)\n, +error_report(Requested memory size greater + than shared object size (% PRIu64 % PRIu64), s-ivshmem_size, (uint64_t)buf.st_size); return -1; } else { @@ -510,7 +509,7 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size) incoming_fd = dup(tmp_fd); if (incoming_fd == -1) { -fprintf(stderr, could not allocate file descriptor %s\n, +error_report(could not allocate file descriptor %s, strerror(errno)); close(tmp_fd); return; @@ -524,7 +523,7 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size) s-max_peer = 0; if (check_shm_size(s, incoming_fd) == -1) { -exit(-1); +exit(1); } /* mmap the region and map into the BAR2 */ @@ -618,13 +617,13 @@ static uint64_t ivshmem_get_size(IVShmemState * s) { value = 30; break; default: -fprintf(stderr, qemu: invalid ram size: %s\n, s-sizearg); +error_report(invalid ram size: %s, s-sizearg); exit(1); } /* BARs must be a power of 2 */ if (!is_power_of_two(value)) { -fprintf(stderr, ivshmem: size must be power of 2\n); +error_report(size must be power of 2); exit(1); } @@ -676,7 +675,7 @@ static int ivshmem_load(QEMUFile* f, void *opaque, int version_id) } if (proxy-role_val == IVSHMEM_PEER) { -fprintf(stderr, ivshmem: 'peer' devices are not migratable\n); +error_report('peer' devices are not migratable); return -EINVAL; } @@ -722,7 +721,7 @@ static int pci_ivshmem_init(PCIDevice *dev) /* IRQFD requires MSI */ if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD) !ivshmem_has_feature(s, IVSHMEM_MSI)) { -fprintf(stderr, ivshmem: ioeventfd/irqfd requires MSI\n); +error_report(ioeventfd/irqfd requires MSI); exit(1); } @@ -733,7 +732,7 @@ static int pci_ivshmem_init(PCIDevice *dev) } else if (strncmp(s-role, master, 7) == 0) { s-role_val = IVSHMEM_MASTER; } else { -fprintf(stderr, ivshmem: 'role' must be 'peer' or 'master'\n); +error_report('role' must be 'peer' or 'master'); exit(1); } } else { @@ -773,8 +772,8 @@ static int pci_ivshmem_init(PCIDevice *dev) * to the ivshmem server to receive the memory region */ if (s-shmobj != NULL) { -fprintf(stderr, WARNING: do not specify both 'chardev' -and 'shm' with ivshmem\n); +error_report(WARNING: do not specify both 'chardev' +and 'shm' with ivshmem); } IVSHMEM_DPRINTF(using shared memory server (socket = %s)\n, @@ -802,7 +801,7 @@ static int pci_ivshmem_init(PCIDevice *dev) int fd; if (s-shmobj == NULL) { -fprintf(stderr, Must specify 'chardev' or 'shm' to ivshmem\n); +error_report(Must specify 'chardev' or 'shm' to ivshmem); exit(1); } @@ -814,18 +813,18 @@ static int pci_ivshmem_init(PCIDevice *dev) S_IRWXU|S_IRWXG|S_IRWXO)) 0) { /* truncate file to length PCI device's memory */ if (ftruncate(fd, s-ivshmem_size) != 0) { -fprintf(stderr, ivshmem: could not
[Qemu-devel] [PATCH 1/2] usb-bus: introduce a wrapper function to check speed
From: Gonglei arei.gong...@huawei.com In this way, we can check speed directly, don't need call usb_device_attach(), which has other conditions, such as checking the chardev is open. Cc: Paolo Bonzini pbonz...@redhat.com Cc: Gerd Hoffmann kra...@redhat.com Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/bus.c | 14 +- include/hw/usb.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/usb/bus.c b/hw/usb/bus.c index b375293..da1eba9 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -478,7 +478,7 @@ static void usb_mask_to_str(char *dest, size_t size, } } -void usb_device_attach(USBDevice *dev, Error **errp) +void usb_check_attach(USBDevice *dev, Error **errp) { USBBus *bus = usb_bus_from_device(dev); USBPort *port = dev-port; @@ -499,6 +499,18 @@ void usb_device_attach(USBDevice *dev, Error **errp) bus-qbus.name, port-path, portspeed); return; } +} + +void usb_device_attach(USBDevice *dev, Error **errp) +{ +USBPort *port = dev-port; +Error *local_err = NULL; + +usb_check_attach(dev, local_err); +if (local_err) { +error_propagate(errp, local_err); +return; +} dev-attached++; usb_attach(port); diff --git a/include/hw/usb.h b/include/hw/usb.h index 8ffbba2..b20b959 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -553,6 +553,7 @@ void usb_release_port(USBDevice *dev); void usb_device_attach(USBDevice *dev, Error **errp); int usb_device_detach(USBDevice *dev); int usb_device_delete_addr(int busnr, int addr); +void usb_check_attach(USBDevice *dev, Error **errp); static inline USBBus *usb_bus_from_device(USBDevice *d) { -- 1.7.12.4
[Qemu-devel] [PATCH 0/2] usb-serial: only check speed once at realize time
From: Gonglei arei.gong...@huawei.com This patch series based on [PATCH v3 00/19] usb: convert device init to realize As Paolo's comments: usb port speed check could be extracted to a separate function usb_check_attach, that is called just once at realize time, even if !s-cs-be_open. Please review, Thanks. :) Gonglei (2): usb-bus: introduce a wrapper function to check speed usb-serial: only check speed once at realize time hw/usb/bus.c| 14 +- hw/usb/dev-serial.c | 16 +--- include/hw/usb.h| 1 + 3 files changed, 23 insertions(+), 8 deletions(-) -- 1.7.12.4
[Qemu-devel] [PATCH 2/2] usb-serial: only check speed once at realize time
From: Gonglei arei.gong...@huawei.com Whatever the chardev is open or not, we should assure the speed is matched each other. So, call usb_check_attach() check speed. And then pass error_abort at all calls to usb_device_attach(). Cc: Paolo Bonzini pbonz...@redhat.com Cc: Gerd Hoffmann kra...@redhat.com Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/dev-serial.c | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index 3784f4a..1cee450 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -451,7 +451,6 @@ static void usb_serial_read(void *opaque, const uint8_t *buf, int size) static void usb_serial_event(void *opaque, int event) { USBSerialState *s = opaque; -Error *local_err = NULL; switch (event) { case CHR_EVENT_BREAK: @@ -461,11 +460,7 @@ static void usb_serial_event(void *opaque, int event) break; case CHR_EVENT_OPENED: if (!s-dev.attached) { -usb_device_attach(s-dev, local_err); -if (local_err) { -qerror_report_err(local_err); -error_free(local_err); -} +usb_device_attach(s-dev, error_abort); } break; case CHR_EVENT_CLOSED: @@ -479,6 +474,7 @@ static void usb_serial_event(void *opaque, int event) static void usb_serial_realize(USBDevice *dev, Error **errp) { USBSerialState *s = DO_UPCAST(USBSerialState, dev, dev); +Error *local_err = NULL; usb_desc_create_serial(dev); usb_desc_init(dev); @@ -489,12 +485,18 @@ static void usb_serial_realize(USBDevice *dev, Error **errp) return; } +usb_check_attach(dev, local_err); +if (local_err) { +error_propagate(errp, local_err); +return; +} + qemu_chr_add_handlers(s-cs, usb_serial_can_read, usb_serial_read, usb_serial_event, s); usb_serial_handle_reset(dev); if (s-cs-be_open !dev-attached) { -usb_device_attach(dev, errp); +usb_device_attach(dev, error_abort); } } -- 1.7.12.4
[Qemu-devel] [PATCH] qemu-socket: Polish errors for connect() and listen() failure
connect() doesn't connect to socket, it connects a socket to an address and, if it's of type SOCK_STREAM, initiates a connection. Scratch to. listen() does set socket to listening mode, but it sounds awkward. Change to listen on socket. Signed-off-by: Markus Armbruster arm...@redhat.com --- include/qapi/qmp/qerror.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index 902d1a7..774e75d 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -155,10 +155,10 @@ void qerror_report_err(Error *err); ERROR_CLASS_GENERIC_ERROR, this feature or command is not currently supported #define QERR_SOCKET_CONNECT_FAILED \ -ERROR_CLASS_GENERIC_ERROR, Failed to connect to socket +ERROR_CLASS_GENERIC_ERROR, Failed to connect socket #define QERR_SOCKET_LISTEN_FAILED \ -ERROR_CLASS_GENERIC_ERROR, Failed to set socket to listening mode +ERROR_CLASS_GENERIC_ERROR, Failed to listen on socket #define QERR_SOCKET_BIND_FAILED \ ERROR_CLASS_GENERIC_ERROR, Failed to bind socket -- 1.9.3
Re: [Qemu-devel] [PATCH v2] ivshmem: use error_report
On 2014/9/19 7:17, Andrew Jones wrote: Replace all the fprintf(stderr, ...) calls with error_report. Also make sure exit() consistently uses the error code 1. A few calls used -1. Signed-off-by: Andrew Jones drjo...@redhat.com --- hw/misc/ivshmem.c | 39 +++ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index bf585b7691998..b3983296f58fa 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -300,8 +300,8 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier * chr = qemu_chr_open_eventfd(eventfd); if (chr == NULL) { -fprintf(stderr, creating eventfd for eventfd %d failed\n, eventfd); -exit(-1); +error_report(creating eventfd for eventfd %d failed, eventfd); +exit(1); } qemu_chr_fe_claim_no_fail(chr); @@ -328,15 +328,14 @@ static int check_shm_size(IVShmemState *s, int fd) { struct stat buf; if (fstat(fd, buf) 0) { -fprintf(stderr, ivshmem: exiting: fstat on fd %d failed: %s\n, +error_report(exiting: fstat on fd %d failed: %s, fd, strerror(errno)); The indentation looks weird, better to fix it.;) More of the same elsewhere. return -1; } if (s-ivshmem_size buf.st_size) { -fprintf(stderr, -IVSHMEM ERROR: Requested memory size greater - than shared object size (% PRIu64 % PRIu64)\n, +error_report(Requested memory size greater + than shared object size (% PRIu64 % PRIu64), s-ivshmem_size, (uint64_t)buf.st_size); return -1; } else { @@ -510,7 +509,7 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size) incoming_fd = dup(tmp_fd); if (incoming_fd == -1) { -fprintf(stderr, could not allocate file descriptor %s\n, +error_report(could not allocate file descriptor %s, strerror(errno)); close(tmp_fd); return; @@ -524,7 +523,7 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size) s-max_peer = 0; if (check_shm_size(s, incoming_fd) == -1) { -exit(-1); +exit(1); } /* mmap the region and map into the BAR2 */ @@ -618,13 +617,13 @@ static uint64_t ivshmem_get_size(IVShmemState * s) { value = 30; break; default: -fprintf(stderr, qemu: invalid ram size: %s\n, s-sizearg); +error_report(invalid ram size: %s, s-sizearg); exit(1); } /* BARs must be a power of 2 */ if (!is_power_of_two(value)) { -fprintf(stderr, ivshmem: size must be power of 2\n); +error_report(size must be power of 2); exit(1); } @@ -676,7 +675,7 @@ static int ivshmem_load(QEMUFile* f, void *opaque, int version_id) } if (proxy-role_val == IVSHMEM_PEER) { -fprintf(stderr, ivshmem: 'peer' devices are not migratable\n); +error_report('peer' devices are not migratable); return -EINVAL; } @@ -722,7 +721,7 @@ static int pci_ivshmem_init(PCIDevice *dev) /* IRQFD requires MSI */ if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD) !ivshmem_has_feature(s, IVSHMEM_MSI)) { -fprintf(stderr, ivshmem: ioeventfd/irqfd requires MSI\n); +error_report(ioeventfd/irqfd requires MSI); exit(1); } @@ -733,7 +732,7 @@ static int pci_ivshmem_init(PCIDevice *dev) } else if (strncmp(s-role, master, 7) == 0) { s-role_val = IVSHMEM_MASTER; } else { -fprintf(stderr, ivshmem: 'role' must be 'peer' or 'master'\n); +error_report('role' must be 'peer' or 'master'); exit(1); } } else { @@ -773,8 +772,8 @@ static int pci_ivshmem_init(PCIDevice *dev) * to the ivshmem server to receive the memory region */ if (s-shmobj != NULL) { -fprintf(stderr, WARNING: do not specify both 'chardev' -and 'shm' with ivshmem\n); +error_report(WARNING: do not specify both 'chardev' +and 'shm' with ivshmem); } IVSHMEM_DPRINTF(using shared memory server (socket = %s)\n, @@ -802,7 +801,7 @@ static int pci_ivshmem_init(PCIDevice *dev) int fd; if (s-shmobj == NULL) { -fprintf(stderr, Must specify 'chardev' or 'shm' to ivshmem\n); +error_report(Must specify 'chardev' or 'shm' to ivshmem); exit(1); } @@ -814,18 +813,18 @@ static int pci_ivshmem_init(PCIDevice *dev) S_IRWXU|S_IRWXG|S_IRWXO)) 0) { /* truncate file to length PCI device's memory */ if (ftruncate(fd,
Re: [Qemu-devel] [PATCH 0/6] pc: bring ACPI table size below to 2.0 levels, try fixing -initrd for good
Hi, However, there is another problem. As the ACPI tables grow, we need to move the address at which linuxboot.bin loads the initrd. This address is placed close to the end of memory, but it is QEMU that tells linuxboot.bin where exactly the initrd is to be loaded. And QEMU cannot really know how much high memory SeaBIOS will use, because QEMU does not know the final e820 memory map. The solution would be to let linuxboot.bin parse the memory map and ignore the suggested initrd base address, but that's tedious. In the meanwhile, we can just assume that most of the need comes from the ACPI tables (which is in fact true: patch 3 adds a fixed 32k extra just in case) and dynamically resize the padding. Hmm. That assumes we are running seabios, where we know how much memory we actually need. IMHO we should either really parse the memory map, or reserve more space. IIRC it doesn't matter that much where we load the initrd. It should not be just after the kernel, because the kernel needs some space to unpack itself and for early allocations such as initial page tables. This is where the common practice to load the initrd high comes from. But whenever we leave 128k or 16m between initrd and top-of-memory doesn't make much of a difference. cheers, Gerd
Re: [Qemu-devel] [PATCH] qemu-socket: Polish errors for connect() and listen() failure
Subject: [Qemu-devel] [PATCH] qemu-socket: Polish errors for connect() and listen() failure connect() doesn't connect to socket, it connects a socket to an address and, if it's of type SOCK_STREAM, initiates a connection. Scratch to. listen() does set socket to listening mode, but it sounds awkward. Change to listen on socket. Signed-off-by: Markus Armbruster arm...@redhat.com --- include/qapi/qmp/qerror.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Reviewed-by: Gonglei arei.gong...@huawei.com And Cc'ing qemu-trivial@ Best regards, -Gonglei diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index 902d1a7..774e75d 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -155,10 +155,10 @@ void qerror_report_err(Error *err); ERROR_CLASS_GENERIC_ERROR, this feature or command is not currently supported #define QERR_SOCKET_CONNECT_FAILED \ -ERROR_CLASS_GENERIC_ERROR, Failed to connect to socket +ERROR_CLASS_GENERIC_ERROR, Failed to connect socket #define QERR_SOCKET_LISTEN_FAILED \ -ERROR_CLASS_GENERIC_ERROR, Failed to set socket to listening mode +ERROR_CLASS_GENERIC_ERROR, Failed to listen on socket #define QERR_SOCKET_BIND_FAILED \ ERROR_CLASS_GENERIC_ERROR, Failed to bind socket -- 1.9.3
Re: [Qemu-devel] [PATCH v1] vl: Fix possible freed memory accessing
zhanghailiang zhang.zhanghaili...@huawei.com writes: The logic of pcmcia_socket_unregister is wrong, which will cause a freed memory accessing Signed-off-by: zhanghailiang zhang.zhanghaili...@huawei.com --- Hi, The function pcmcia_socket_unregister seemes to be unused, Should it be removed? Thanks. I think we should remove the whole thing: pcmcia_sockets, pcmcia_socket_register(), pcmcia_socket_unregister, pcmcia_info(). Here's why. It serves just one purpose: info pcmcia. HMP-only, therefore not a stable interface. But is it a useful one? The only caller of pcmcia_socket_register() is pxa2xx_pcmcia_realize(), of device model pxa2xx-pcmcia. As far as I can tell, used only by a couple of ARM boards: verdex, mainstone, akita, spitz, borzoi, terrier, z2, connex, tosa. Of these, only akita, spitz, borzoi, terrier and tosa insert a card into the slot, and they do so right on board initialization. Nothing ever ejects a card from a slot. Therefore, info pcmcia effectively prints a fixed, machine-specific string so far. Doesn't sound useful to me. If we acquire PCMCIA devices where querying status is interesting, we'll want a QMP command, so this code will be pretty much useless. Peter M., what do you think?
Re: [Qemu-devel] [PATCH 0/6] pc: bring ACPI table size below to 2.0 levels, try fixing -initrd for good
Il 19/09/2014 09:36, Gerd Hoffmann ha scritto: Hmm. That assumes we are running seabios, where we know how much memory we actually need. Right. However, note that this only affects one patch in the series (patch 3). Patches 1-2 are useful to unify Xen-specific behavior with other hypervisors, and patches 4-6 are useful to future-proof ACPI table sizes for migration. IMHO we should either really parse the memory map, or reserve more space. I agree. However, we need to cater for a fixed initrd loading address until this is done. And even after linuxboot.bin is improved, the older version will be used when migrating for older QEMU machine types, so it is important to have a decent fallback. Paolo
Re: [Qemu-devel] [PATCH 0/2] usb-serial: only check speed once at realize time
Il 19/09/2014 09:25, arei.gong...@huawei.com ha scritto: From: Gonglei arei.gong...@huawei.com This patch series based on [PATCH v3 00/19] usb: convert device init to realize As Paolo's comments: usb port speed check could be extracted to a separate function usb_check_attach, that is called just once at realize time, even if !s-cs-be_open. Please review, Thanks. :) Gonglei (2): usb-bus: introduce a wrapper function to check speed usb-serial: only check speed once at realize time hw/usb/bus.c| 14 +- hw/usb/dev-serial.c | 16 +--- include/hw/usb.h| 1 + 3 files changed, 23 insertions(+), 8 deletions(-) Reviewed-by: Paolo Bonzini pbonz...@redhat.com
Re: [Qemu-devel] [PATCH v1] vl: Fix possible freed memory accessing
Il 19/09/2014 05:37, zhanghailiang ha scritto: The logic of pcmcia_socket_unregister is wrong, which will cause a freed memory accessing Signed-off-by: zhanghailiang zhang.zhanghaili...@huawei.com --- Hi, The function pcmcia_socket_unregister seemes to be unused, Should it be removed? Thanks. Perhaps---however, the patch silences a Coverity warning, so it is worthwhile. Thanks for doing this! Reviewed-by: Paolo Bonzini pbonz...@redhat.com Paolo
Re: [Qemu-devel] [PATCH 0/2] usb-serial: only check speed once at realize time
Il 19/09/2014 09:25, arei.gong...@huawei.com ha scritto: From: Gonglei arei.gong...@huawei.com This patch series based on [PATCH v3 00/19] usb: convert device init to realize As Paolo's comments: usb port speed check could be extracted to a separate function usb_check_attach, that is called just once at realize time, even if !s-cs-be_open. Please review, Thanks. :) Gonglei (2): usb-bus: introduce a wrapper function to check speed usb-serial: only check speed once at realize time hw/usb/bus.c| 14 +- hw/usb/dev-serial.c | 16 +--- include/hw/usb.h| 1 + 3 files changed, 23 insertions(+), 8 deletions(-) Reviewed-by: Paolo Bonzini pbonz...@redhat.com Thanks ! Best regards, -Gonglei
Re: [Qemu-devel] [PATCH 0/2] pflash (UEFI varstore) migration shortcut for libvirt
Il 19/09/2014 08:48, Alexey Kardashevskiy ha scritto: Right now we use NVRAM on sPAPR as: -drive id=id3,if=none,file=qemu_nvram.img -global spapr-nvram.drive=id3 So the NVRAM file is BlockDriverState and HMP's migrate -b copies the content just fine. What is missing here? Thanks. migrate -b is a big hammer, because it transfers all disks. In some cases it is useful to have shared storage for disks and non-shared storage for variable stores. For UEFI, we are using RAM migration to transfer non-volatile RAM from the source to the destination. This is done by loading the whole contents of nvram into a RAM MemoryRegion at VM startup, and storing it at postload time. The latter is done with this patch. Paolo
Re: [Qemu-devel] migration: qemu-coroutine-lock.c:141: qemu_co_mutex_unlock: Assertion `mutex-locked == 1' failed
On 09/18/2014 07:56 PM, Paolo Bonzini wrote: Il 18/09/2014 05:26, Alexey Kardashevskiy ha scritto: On 09/18/2014 01:07 AM, Stefan Hajnoczi wrote: On Wed, Sep 17, 2014 at 2:44 PM, Alexey Kardashevskiy a...@ozlabs.ru wrote: On 09/17/2014 07:25 PM, Paolo Bonzini wrote: btw any better idea of a hack to try? Testers are pushing me - they want to upgrade the broken setup and I am blocking them :) Thanks! Paolo's qemu_co_mutex_lock(s-lock) idea in qcow2_invalidate_cache() is good. Have you tried that patch? Yes, did not help. I haven't checked the qcow2 code whether that works properly across bdrv_close() (is the lock freed?) but in principle that's how you protect against concurrent I/O. I thought we have to avoid qemu_coroutine_yield() in this particular case. I fail to see how the locks may help if we still do yeild. But the whole thing is already way behind of my understanding :) For example - how many BlockDriverState things are layered here? NBD - QCOW2 - RAW? No, this is an NBD server. So we have three users of the same QCOW2 image: migration, NBD server and virtio disk (not active while the bug happens, and thus not depicted): NBD server -QCOW2 - migration | v File The problem is that the NBD server accesses the QCOW2 image while migration does qcow2_invalidate_cache. Ufff. Cool. Anyway, the qemu_co_mutex_lock(s-lock) hack does not work as after qcow2_close() the lock is cleared and qemu_co_mutex_unlock(s-lock) fails. Moving the lock to BlockDriverState caused weird side effects, debugging... -- Alexey
Re: [Qemu-devel] [RFC v2 1/3] blockdev: Add function to search for orphaned drives
John Snow js...@redhat.com writes: Signed-off-by: John Snow js...@redhat.com --- blockdev.c| 19 +++ include/sysemu/blockdev.h | 1 + vl.c | 5 + 3 files changed, 25 insertions(+) diff --git a/blockdev.c b/blockdev.c index b361fbb..5e7c93a 100644 --- a/blockdev.c +++ b/blockdev.c @@ -166,6 +166,25 @@ DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit) return NULL; } +DriveInfo *drive_check_orphaned(void) +{ +DriveInfo *dinfo; +DriveInfo *ret = NULL; + +QTAILQ_FOREACH(dinfo, drives, next) { +/* If dev is NULL, it has no device attached. + * If drv is non-NULL, it has a file attached. + * If both conditions are true, it is possibly an oversight. */ Suggest to spell out dinfo-bdrv-dev and dinfo-bdrv-drv. File attached is imprecise. BDS member drv is non-null betwen bdrv_open() and bdrv_close(). A BDS with null drv means empty, in the sense of no medium. +if ((dinfo-bdrv-dev == NULL) (dinfo-bdrv-drv != NULL)) { +fprintf(stderr, Orphaned drive: id=%s,if=%s,file=%s\n, +dinfo-id, if_name[dinfo-type], dinfo-bdrv-filename); +ret = dinfo; +} +} Please prefix Warning: to make the nature of this message more explicit. Orphaned drive might not be obvious to all users, but it's concise, and no worse than the has no peer we use for NICs. You warn when a non-empty drive is not used by a device model. This warns when you create one with -drive if=none for future use in the monitor. I guess that's fine. It doesn't warn for empty drives. I doubt empty should make a difference. I think the condition to check is has the board failed to pick up a drive that is meant to be picked up by the board: dinfo-type != IF_NONE !dinfo-bdrv-dev I guess this can warn about default drives, because we blindly add them whether the boards wants them or not. Stupidest solution that could possibly work: add a flag to DriveInfo to suppress the warning for them. Better solution: don't add them unless the board wants them. I tried that before, but my solution[*] went nowhere. If you're interested in trying again, let me know, and I'll explain. + +return ret; +} + DriveInfo *drive_get_by_index(BlockInterfaceType type, int index) { return drive_get(type, diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index 23a5d10..25d52d2 100644 --- a/include/sysemu/blockdev.h +++ b/include/sysemu/blockdev.h @@ -46,6 +46,7 @@ struct DriveInfo { }; DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit); +DriveInfo *drive_check_orphaned(void); DriveInfo *drive_get_by_index(BlockInterfaceType type, int index); int drive_get_max_bus(BlockInterfaceType type); DriveInfo *drive_get_next(BlockInterfaceType type); diff --git a/vl.c b/vl.c index 5db0d08..e095bcd 100644 --- a/vl.c +++ b/vl.c @@ -4457,6 +4457,11 @@ int main(int argc, char **argv, char **envp) if (qemu_opts_foreach(qemu_find_opts(device), device_init_func, NULL, 1) != 0) exit(1); +/* anybody left over? */ +if (drive_check_orphaned()) { +fprintf(stderr, Warning: found drives without a backing device.\n); +} + net_check_clients(); ds = init_displaystate(); [*] https://lists.nongnu.org/archive/html/qemu-devel/2012-08/msg02993.html
Re: [Qemu-devel] [PATCH v2] ivshmem: use error_report
On 2014/9/19 15:34, zhanghailiang wrote: On 2014/9/19 7:17, Andrew Jones wrote: Replace all the fprintf(stderr, ...) calls with error_report. Also make sure exit() consistently uses the error code 1. A few calls used -1. Signed-off-by: Andrew Jones drjo...@redhat.com --- hw/misc/ivshmem.c | 39 +++ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index bf585b7691998..b3983296f58fa 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -300,8 +300,8 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier * chr = qemu_chr_open_eventfd(eventfd); if (chr == NULL) { -fprintf(stderr, creating eventfd for eventfd %d failed\n, eventfd); -exit(-1); +error_report(creating eventfd for eventfd %d failed, eventfd); +exit(1); } qemu_chr_fe_claim_no_fail(chr); @@ -328,15 +328,14 @@ static int check_shm_size(IVShmemState *s, int fd) { struct stat buf; if (fstat(fd, buf) 0) { -fprintf(stderr, ivshmem: exiting: fstat on fd %d failed: %s\n, +error_report(exiting: fstat on fd %d failed: %s, fd, strerror(errno)); The indentation looks weird, better to fix it.;) More of the same elsewhere. Er, actually, maybe for print like function, it is no need to indent like other function. So just ignore this comment, Sorry.;) return -1; } if (s-ivshmem_size buf.st_size) { -fprintf(stderr, -IVSHMEM ERROR: Requested memory size greater - than shared object size (% PRIu64 % PRIu64)\n, +error_report(Requested memory size greater + than shared object size (% PRIu64 % PRIu64), s-ivshmem_size, (uint64_t)buf.st_size); return -1; } else { @@ -510,7 +509,7 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size) incoming_fd = dup(tmp_fd); if (incoming_fd == -1) { -fprintf(stderr, could not allocate file descriptor %s\n, +error_report(could not allocate file descriptor %s, strerror(errno)); close(tmp_fd); return; @@ -524,7 +523,7 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size) s-max_peer = 0; if (check_shm_size(s, incoming_fd) == -1) { -exit(-1); +exit(1); } /* mmap the region and map into the BAR2 */ @@ -618,13 +617,13 @@ static uint64_t ivshmem_get_size(IVShmemState * s) { value = 30; break; default: -fprintf(stderr, qemu: invalid ram size: %s\n, s-sizearg); +error_report(invalid ram size: %s, s-sizearg); exit(1); } /* BARs must be a power of 2 */ if (!is_power_of_two(value)) { -fprintf(stderr, ivshmem: size must be power of 2\n); +error_report(size must be power of 2); exit(1); } @@ -676,7 +675,7 @@ static int ivshmem_load(QEMUFile* f, void *opaque, int version_id) } if (proxy-role_val == IVSHMEM_PEER) { -fprintf(stderr, ivshmem: 'peer' devices are not migratable\n); +error_report('peer' devices are not migratable); return -EINVAL; } @@ -722,7 +721,7 @@ static int pci_ivshmem_init(PCIDevice *dev) /* IRQFD requires MSI */ if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD) !ivshmem_has_feature(s, IVSHMEM_MSI)) { -fprintf(stderr, ivshmem: ioeventfd/irqfd requires MSI\n); +error_report(ioeventfd/irqfd requires MSI); exit(1); } @@ -733,7 +732,7 @@ static int pci_ivshmem_init(PCIDevice *dev) } else if (strncmp(s-role, master, 7) == 0) { s-role_val = IVSHMEM_MASTER; } else { -fprintf(stderr, ivshmem: 'role' must be 'peer' or 'master'\n); +error_report('role' must be 'peer' or 'master'); exit(1); } } else { @@ -773,8 +772,8 @@ static int pci_ivshmem_init(PCIDevice *dev) * to the ivshmem server to receive the memory region */ if (s-shmobj != NULL) { -fprintf(stderr, WARNING: do not specify both 'chardev' -and 'shm' with ivshmem\n); +error_report(WARNING: do not specify both 'chardev' +and 'shm' with ivshmem); } IVSHMEM_DPRINTF(using shared memory server (socket = %s)\n, @@ -802,7 +801,7 @@ static int pci_ivshmem_init(PCIDevice *dev) int fd; if (s-shmobj == NULL) { -fprintf(stderr, Must specify 'chardev' or 'shm' to ivshmem\n); +error_report(Must specify 'chardev' or 'shm' to ivshmem); exit(1); } @@ -814,18 +813,18 @@ static int
Re: [Qemu-devel] migration: qemu-coroutine-lock.c:141: qemu_co_mutex_unlock: Assertion `mutex-locked == 1' failed
Am 16.09.2014 um 14:59 hat Paolo Bonzini geschrieben: Il 16/09/2014 14:52, Kevin Wolf ha scritto: Yes, that's true. We can't fix this problem in qcow2, though, because it's a more general one. I think we must make sure that bdrv_invalidate_cache() doesn't yield. Either by forbidding to run bdrv_invalidate_cache() in a coroutine and moving the problem to the caller (where and why is it even called from a coroutine?), or possibly by creating a new coroutine for the driver callback and running that in a nested event loop that only handles bdrv_invalidate_cache() callbacks, so that the NBD server doesn't get a chance to process new requests in this thread. Incoming migration runs in a coroutine (the coroutine entry point is process_incoming_migration_co). But everything after qemu_fclose() can probably be moved into a separate bottom half, so that it gets out of coroutine context. Alexey, you should probably rather try this (and add a bdrv_drain_all() in bdrv_invalidate_cache) than messing around with qcow2 locks. This isn't a problem that can be completely fixed in qcow2. Kevin
[Qemu-devel] [PATCH 0/2] serial: cleanups for physical serial port passthrough
Patch 1 ensures that the serial port state is the same at VM startup and after reset. Patch 2 ensures that the poll_msl field is computed at reset time (rather than arbitrarily later), so that it becomes -1 for serial ports backed by PTYs, sockets, etc. Please review! Paolo Paolo Bonzini (2): serial: reset state at startup serial: check if backed by a physical serial port at realize time hw/char/serial.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.1.0
[Qemu-devel] [PATCH 2/2] serial: check if backed by a physical serial port at realize time
Right now, s-poll_msl may linger at 0 value for an arbitrarily long time, until serial_update_msl is called for the first time. This is unnecessary, and will lead to the s-poll_msl field being unnecessarily migrated. We can call serial_update_msl immediately at realize time (via serial_reset) and be done with it. The memory-mapped UART was already doing that, but not the ISA and PCI variants. Regarding the delta bits, be consistent with what serial_reset does when the serial port is not backed by a physical serial port, and always clear them at reset time. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/char/serial.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/char/serial.c b/hw/char/serial.c index 4523ccb..e1dd0c9 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -650,6 +650,9 @@ static void serial_reset(void *opaque) s-thr_ipending = 0; s-last_break_enable = 0; qemu_irq_lower(s-irq); + +serial_update_msl(s); +s-msr = ~UART_MSR_ANY_DELTA; } void serial_realize_core(SerialState *s, Error **errp) @@ -780,7 +783,5 @@ SerialState *serial_mm_init(MemoryRegion *address_space, memory_region_init_io(s-io, NULL, serial_mm_ops[end], s, serial, 8 it_shift); memory_region_add_subregion(address_space, base, s-io); - -serial_update_msl(s); return s; } -- 2.1.0
[Qemu-devel] [PATCH 1/2] serial: reset state at startup
When a serial port is started, its initial state is all zero. Make it consistent with reset state instead. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/char/serial.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/char/serial.c b/hw/char/serial.c index 764e184..4523ccb 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -668,6 +668,7 @@ void serial_realize_core(SerialState *s, Error **errp) serial_event, s); fifo8_create(s-recv_fifo, UART_FIFO_LENGTH); fifo8_create(s-xmit_fifo, UART_FIFO_LENGTH); +serial_reset(s); } void serial_exit_core(SerialState *s) -- 2.1.0
Re: [Qemu-devel] [RFC] vfio: migration to trace points
On Wed, Sep 03, 2014 at 09:45:14AM +0100, Eric Auger wrote: This patch removes all DPRINTF and replace them by trace points. A few DPRINTF used in error cases were transformed into error_report. Signed-off-by: Eric Auger eric.au...@linaro.org The subject line says RFC. Are you proposing this patch for merge? Did you want me to take it into the tracing tree? Stefan pgpDRNAi9HxKa.pgp Description: PGP signature
Re: [Qemu-devel] [PATCH v3 0/3] block: Always compile virtio-blk dataplane
Il 10/09/2014 08:17, Fam Zheng ha scritto: v3: Fix -ENOBUFS. v2: Import virtio_vring.h. Fam Zheng (3): virtio: Import virtio_vring.h vring: Better error handling if num is too large block: Always compile virtio-blk dataplane configure | 21 + hw/block/Makefile.objs | 2 +- hw/block/virtio-blk.c | 20 + hw/net/vhost_net.c | 2 +- hw/virtio/Makefile.objs | 2 +- hw/virtio/dataplane/vring.c | 3 +- include/hw/virtio/dataplane/vring.h | 2 +- include/hw/virtio/virtio-blk.h | 2 - include/hw/virtio/virtio_ring.h | 167 linux-headers/linux/vhost.h | 2 +- 10 files changed, 178 insertions(+), 45 deletions(-) create mode 100644 include/hw/virtio/virtio_ring.h Reviewed-by: Paolo Bonzini pbonz...@redhat.com
[Qemu-devel] [PATCH 1/1] vpc.c: Add VHD resize support
This patch introduces resize support for dynamic and fixed VHD images. Note that differencing VHD images do not support this operation. In order to resize dynamic VHDs, the BAT region may need to be extended. This may require moving the first data blocks, making room for it to expand. This required updating the according BAT entries for the moved blocks as well, as well as initializing the new BAT entries. In case of fixed VHDs, the only thing that needs to be done is moving and updating the footer. Note that this patch assumes that all the data blocks are written right after the BAT. Signed-off-by: Lucian Petrut lpet...@cloudbasesolutions.com --- block/vpc.c | 179 +++- 1 file changed, 177 insertions(+), 2 deletions(-) diff --git a/block/vpc.c b/block/vpc.c index 055efc4..f3895cb 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -417,7 +417,7 @@ static inline int64_t get_sector_offset(BlockDriverState *bs, * * Returns 0 on success and 0 on error */ -static int rewrite_footer(BlockDriverState* bs) +static int rewrite_footer(BlockDriverState* bs, bool update_header) { int ret; BDRVVPCState *s = bs-opaque; @@ -427,6 +427,12 @@ static int rewrite_footer(BlockDriverState* bs) if (ret 0) return ret; +if (update_header) { +ret = bdrv_pwrite_sync(bs-file, 0, s-footer_buf, HEADER_SIZE); +if (ret 0) +return ret; +} + return 0; } @@ -466,7 +472,7 @@ static int64_t alloc_block(BlockDriverState* bs, int64_t sector_num) // Write new footer (the old one will be overwritten) s-free_data_block_offset += s-block_size + s-bitmap_size; -ret = rewrite_footer(bs); +ret = rewrite_footer(bs, false); if (ret 0) goto fail; @@ -852,6 +858,174 @@ out: return ret; } + +static int vpc_truncate(BlockDriverState *bs, int64_t offset) +{ +BDRVVPCState *s = bs-opaque; +VHDFooter *footer = (VHDFooter *) s-footer_buf; +VHDDynDiskHeader *dyndisk_header; +void *buf = NULL; +int64_t new_total_sectors, old_bat_size, new_bat_size, +block_offset, new_block_offset, bat_offset; +int32_t bat_value, data_blocks_required; +int ret = 0; +uint16_t cyls = 0; +uint8_t heads = 0; +uint8_t secs_per_cyl = 0; +uint32_t new_num_bat_entries; +uint64_t index, block_index, new_bat_right_limit; + +if (offset 511) { +error_report(The new size must be a multiple of 512.); +return -EINVAL; +} + +if (offset bs-total_sectors * 512) { +error_report(Shrinking vhd images is not supported.); +return -ENOTSUP; +} + +if (cpu_to_be32(footer-type) == VHD_DIFFERENCING){ +error_report(Resizing differencing vhd images is not supported.); +return -ENOTSUP; +} + +old_bat_size = (s-max_table_entries * 4 + 511) ~511; +new_total_sectors = offset / BDRV_SECTOR_SIZE; + +for (index = 0; new_total_sectors (int64_t)cyls * heads * secs_per_cyl; +index++) { +if (calculate_geometry(new_total_sectors + index, cyls, heads, + secs_per_cyl)) +{ +return -EFBIG; +} +} +new_total_sectors = (int64_t) cyls * heads * secs_per_cyl; +new_num_bat_entries = (new_total_sectors + s-block_size / 512) / + (s-block_size / 512); + +if (cpu_to_be32(footer-type) == VHD_DYNAMIC){ +new_bat_size = (new_num_bat_entries * 4 + 511) ~511; +/* Number of blocks required for extending the BAT */ +data_blocks_required = (new_bat_size - old_bat_size + +s-block_size - 1) / s-block_size; +new_bat_right_limit = s-bat_offset + old_bat_size + + data_blocks_required * + (s-block_size + s-bitmap_size); + +for (block_index = 0; block_index +data_blocks_required; block_index++){ +/* + * The BAT has to be extended. We'll have to move the first + * data block(s) to the end of the file, making room for the + * BAT to expand. Also, the BAT entries have to be updated for + * the moved blocks. + */ + +block_offset = s-bat_offset + old_bat_size + + block_index * (s-block_size + s-bitmap_size); +if (block_offset = s-free_data_block_offset){ +/* +* Do not allocate a new block for the BAT if no data blocks +* were previously allocated to the vhd image. +*/ +s-free_data_block_offset += (new_bat_size - old_bat_size); +break; +} + +if (block_index == 0){ +buf = g_malloc(s-block_size + s-bitmap_size); +} + +ret = bdrv_pread(bs-file, block_offset, buf, +
Re: [Qemu-devel] [PATCH 1/2] serial: reset state at startup
On 2014/9/19 16:54, Paolo Bonzini wrote: When a serial port is started, its initial state is all zero. Make it consistent with reset state instead. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/char/serial.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/char/serial.c b/hw/char/serial.c index 764e184..4523ccb 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -668,6 +668,7 @@ void serial_realize_core(SerialState *s, Error **errp) serial_event, s); It should just follow qemu_register_reset(serial_reset, s). fifo8_create(s-recv_fifo, UART_FIFO_LENGTH); fifo8_create(s-xmit_fifo, UART_FIFO_LENGTH); +serial_reset(s); Or at least we should push this before this pair of fifo8_create() since static void serial_reset(void *opaque) { ... fifo8_reset(s-recv_fifo); fifo8_reset(s-xmit_fifo); Thanks Tiejun } void serial_exit_core(SerialState *s)
Re: [Qemu-devel] [RFC PATCH v3] Support vhd type VHD_DIFFERENCING
On Wed, Sep 10, 2014 at 09:32:15PM +0800, Xiaodong Gong wrote: Now qemu only supports vhd type VHD_FIXED and VHD_DYNAMIC, so qemu can't read snapshot volume of vhd, and can't support other storage features of vhd file. This patch add read parent information in function vpc_open, read bitmap in vpc_read, and change bitmap in vpc_write. Signed-off-by: Xiaodong Gong gordon@localhost.localdomain --- block/vpc.c | 355 -- include/block/block_int.h | 6 +- 2 files changed, 288 insertions(+), 73 deletions(-) Philipp, any comments on v3? diff --git a/block/vpc.c b/block/vpc.c index c024b4c..2ff2bba 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -33,13 +33,18 @@ /**/ #define HEADER_SIZE 512 +#define DYNAMIC_HEADER_SIZE 1024 +#define PARENT_LOCATOR_NUM 8 +#define PARENT_PREFIX_LEN 7 /* such as file:// */ +#define TBBATMAP_HEAD_SIZE 28 +#define PLATFORM_MACX 0x5863614d /* big endian */ //#define CACHE enum vhd_type { VHD_FIXED = 2, VHD_DYNAMIC = 3, -VHD_DIFFERENCING= 4, +VHD_DIFF= 4, }; // Seconds since Jan 1, 2000 0:00:00 (UTC) @@ -138,6 +143,15 @@ typedef struct BDRVVPCState { Error *migration_blocker; } BDRVVPCState; +typedef struct vhd_tdbatmap_header { +char magic[8]; /* always tdbatmap */ + +uint64_t batmap_offset; +uint32_t batmap_size; +uint32_t batmap_version; +uint32_t checksum; +} QEMU_PACKED VHDTdBatmapHeader; + static uint32_t vpc_checksum(uint8_t* buf, size_t size) { uint32_t res = 0; @@ -153,7 +167,7 @@ static uint32_t vpc_checksum(uint8_t* buf, size_t size) static int vpc_probe(const uint8_t *buf, int buf_size, const char *filename) { if (buf_size = 8 !strncmp((char *)buf, conectix, 8)) - return 100; +return 100; return 0; } @@ -164,11 +178,17 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, int i; VHDFooter *footer; VHDDynDiskHeader *dyndisk_header; -uint8_t buf[HEADER_SIZE]; +uint8_t buf[DYNAMIC_HEADER_SIZE]; +uint8_t tdbatmap_header_buf[TBBATMAP_HEAD_SIZE]; uint32_t checksum; uint64_t computed_size; -int disk_type = VHD_DYNAMIC; +uint32_t disk_type; int ret; +VHDTdBatmapHeader *tdbatmap_header; +int parent_locator_offset = 0; +int64_t data_offset = 0; +int data_length = 0; +uint32_t platform; ret = bdrv_pread(bs-file, 0, s-footer_buf, HEADER_SIZE); if (ret 0) { @@ -176,6 +196,8 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, } footer = (VHDFooter *) s-footer_buf; +disk_type = be32_to_cpu(footer-type); + if (strncmp(footer-creator, conectix, 8)) { int64_t offset = bdrv_getlength(bs-file); if (offset 0) { @@ -230,9 +252,9 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, goto fail; } -if (disk_type == VHD_DYNAMIC) { +if (disk_type == VHD_DYNAMIC || disk_type == VHD_DIFF) { ret = bdrv_pread(bs-file, be64_to_cpu(footer-data_offset), buf, - HEADER_SIZE); + DYNAMIC_HEADER_SIZE); if (ret 0) { goto fail; } @@ -286,6 +308,63 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, s-free_data_block_offset = (s-bat_offset + (s-max_table_entries * 4) + 511) ~511; +/* Read tdbatmap header by offset */ +ret = bdrv_pread(bs-file, s-free_data_block_offset, +tdbatmap_header_buf, TBBATMAP_HEAD_SIZE); +if (ret 0) { +goto fail; +} + +tdbatmap_header = (VHDTdBatmapHeader *) tdbatmap_header_buf; +if (!strncmp(tdbatmap_header-magic, tdbatmap, 8)) { +s-free_data_block_offset = +be32_to_cpu(tdbatmap_header-batmap_size) * 512 ++ be64_to_cpu(tdbatmap_header-batmap_offset); +} + +/* Read backing file location from dyn header table */ +if (dyndisk_header-parent_name[0] || dyndisk_header-parent_name[1]) { +for (i = 0; i PARENT_LOCATOR_NUM; i++) { +data_offset = + be64_to_cpu(dyndisk_header-parent_locator[i].data_offset); +data_length = + be32_to_cpu(dyndisk_header-parent_locator[i].data_length); +platform = dyndisk_header-parent_locator[i].platform; + +if (platform == PLATFORM_MACX) { +if (data_offset + PARENT_PREFIX_LEN +s-max_table_entries * s-block_size) { +goto fail; +} +if (data_length - PARENT_PREFIX_LEN PARENT_MAX_LOCATOR)
Re: [Qemu-devel] [RFC PATCH v2 00/10] virtio-scsi: Dataplane on single iothread
Il 06/08/2014 07:34, Fam Zheng ha scritto: Hi all, This series adds iothread property to virtio-scsi in a way just similar to virtio-blk, and turns all scsi devices to run on top of it. Example: -object iothread,id=iothread-1 \ -device virtio-scsi-pci,id=virtio-scsi-bus-0,iothread=iothread-1 \ -drive file=guest.img,id=scsi-disk-1,if=none,cache=none,aio=native \ -device scsi-disk,lun=1,drive=scsi-disk-1,id=scsi-disk-1 It uses irqfd, ioeventfd and vring in a way just like virtio-blk does now. Please review the general approach and see if major points are missed in terms of thread safety and completeness of the moved things from original context to iothread context. Note that the used vring is not function complete compared to virtqueue implementation, because of its lacking of MMIO handling. So this is just an RFC. Migration hasn't been looked into yet, either. Assigning multiple iothreads is supposed to be worked on top of this as well, but it's not thoroughly planned yet. Thanks, Fam Fam Zheng (10): virtio: Compile vring code unconditionally virtio-scsi: Split virtio_scsi_handle_cmd_req from virtio_scsi_handle_cmd virtio-scsi: Split virtio_scsi_handle_ctrl_req from virtio_scsi_handle_ctrl virtio-scsi: Add VirtIOSCSIVring in VirtIOSCSIReq virtio-scsi: Make virtio_scsi_init_req public virtio-scsi: Make virtio_scsi_free_req public virtio-scsi: Make virtio_scsi_push_event public virtio-scsi: Add 'iothread' property to virtio-scsi-pci virtio-scsi-dataplane: Code to run virtio-scsi on iothread virtio-scsi: Hook up with dataplane hw/scsi/Makefile.objs | 2 +- hw/scsi/virtio-scsi-dataplane.c | 219 + hw/scsi/virtio-scsi.c | 260 +--- hw/virtio/Makefile.objs | 2 +- hw/virtio/virtio-pci.c | 2 + include/hw/virtio/virtio-scsi.h | 65 ++ 6 files changed, 450 insertions(+), 100 deletions(-) create mode 100644 hw/scsi/virtio-scsi-dataplane.c I'm applying the patches to scsi-next. However, please resubmit the last two with the review comments addressed. I'm only pushing them so that we don't both spend time rebasing the branch. Thanks, Paolo Thanks
Re: [Qemu-devel] [RFC PATCH v2 09/10] virtio-scsi-dataplane: Code to run virtio-scsi on iothread
Il 06/08/2014 07:35, Fam Zheng ha scritto: This implements the core part of dataplane feature of virtio-scsi. A few fields are added in VirtIOSCSICommon to maintain the dataplane status. These fields are managed by a new source file: virtio-scsi-dataplane.c. Most code in this file will run on an iothread, unless otherwise commented as in a global mutex context, such as those functions to start, stop and setting the iothread property. Upon start, we set up guest/host event notifiers, in a same way as virtio-blk does. The handlers then pop request from vring and call into virtio-scsi.c functions to process it. So we need to make sure make all those called functions work with iothread, too. Signed-off-by: Fam Zheng f...@redhat.com --- hw/scsi/Makefile.objs | 2 +- hw/scsi/virtio-scsi-dataplane.c | 219 include/hw/virtio/virtio-scsi.h | 19 3 files changed, 239 insertions(+), 1 deletion(-) create mode 100644 hw/scsi/virtio-scsi-dataplane.c diff --git a/hw/scsi/Makefile.objs b/hw/scsi/Makefile.objs index 121ddc5..40c79d3 100644 --- a/hw/scsi/Makefile.objs +++ b/hw/scsi/Makefile.objs @@ -8,6 +8,6 @@ common-obj-$(CONFIG_ESP_PCI) += esp-pci.o obj-$(CONFIG_PSERIES) += spapr_vscsi.o ifeq ($(CONFIG_VIRTIO),y) -obj-y += virtio-scsi.o +obj-y += virtio-scsi.o virtio-scsi-dataplane.o obj-$(CONFIG_VHOST_SCSI) += vhost-scsi.o endif diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c new file mode 100644 index 000..d077b67 --- /dev/null +++ b/hw/scsi/virtio-scsi-dataplane.c @@ -0,0 +1,219 @@ +/* + * Virtio SCSI dataplane + * + * Copyright Red Hat, Inc. 2014 + * + * Authors: + * Fam Zheng f...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#include hw/virtio/virtio-scsi.h +#include qemu/error-report.h +#include hw/scsi/scsi.h +#include block/scsi.h +#include hw/virtio/virtio-bus.h +#include hw/virtio/virtio-access.h +#include stdio.h + +/* Context: QEMU global mutex held */ +void virtio_scsi_set_iothread(VirtIOSCSICommon *s, IOThread *iothread) +{ +BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s))); +VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + +s-ctx = iothread_get_aio_context(s-conf.iothread); assert that it's NULL? + +/* Don't try if transport does not support notifiers. */ +if (!k-set_guest_notifiers || !k-set_host_notifier) { +fprintf(stderr, virtio-scsi: Failed to set iothread + (transport does not support notifiers)); +exit(1); +} +} + +static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSICommon *s, + VirtQueue *vq, + EventNotifierHandler *handler, + int n) +{ +BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s))); +VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); +VirtIOSCSIVring *r = g_slice_new(VirtIOSCSIVring); + +/* Set up virtqueue notify */ +if (k-set_host_notifier(qbus-parent, n, true) != 0) { +fprintf(stderr, virtio-scsi: Failed to set host notifier\n); +exit(1); +} +r-host_notifier = *virtio_queue_get_host_notifier(vq); +r-guest_notifier = *virtio_queue_get_guest_notifier(vq); +aio_set_event_notifier(s-ctx, r-host_notifier, handler); + +r-parent = s; + +if (!vring_setup(r-vring, VIRTIO_DEVICE(s), n)) { +fprintf(stderr, virtio-scsi: VRing setup failed\n); +exit(1); +} +return r; +} + +VirtIOSCSIReq *virtio_scsi_pop_req_vring(VirtIOSCSI *s, + VirtIOSCSIVring *vring) +{ +VirtIOSCSIReq *req = virtio_scsi_init_req(s, NULL); +int r; + +req-vring = vring; +r = vring_pop((VirtIODevice *)s, vring-vring, req-elem); +if (r 0) { +virtio_scsi_free_req(req); +req = NULL; +} +return req; +} + +void virtio_scsi_vring_push_notify(VirtIOSCSIReq *req) +{ +vring_push(req-vring-vring, req-elem, + req-qsgl.size + req-resp_iov.size); +event_notifier_set(req-vring-guest_notifier); +} + +static void virtio_scsi_iothread_handle_ctrl(EventNotifier *notifier) +{ +VirtIOSCSIVring *vring = container_of(notifier, + VirtIOSCSIVring, host_notifier); +VirtIOSCSI *s = VIRTIO_SCSI(vring-parent); +VirtIOSCSIReq *req; + +event_notifier_test_and_clear(notifier); +while ((req = virtio_scsi_pop_req_vring(s, vring))) { +virtio_scsi_handle_ctrl_req(s, req); +} +} + +static void virtio_scsi_iothread_handle_event(EventNotifier *notifier) +{ +VirtIOSCSIVring *vring = container_of(notifier, +
Re: [Qemu-devel] [RFC PATCH v2 10/10] virtio-scsi: Hook up with dataplane
Il 06/08/2014 07:35, Fam Zheng ha scritto: This enables the virtio-scsi-dataplane code by setting the iothread in virtio-scsi device, and makes any function that is called by back from dataplane to cooperate with the caller: they need to be vring/iothread aware when handling the requests and using scsi devices on the bus. Signed-off-by: Fam Zheng f...@redhat.com --- hw/scsi/virtio-scsi.c | 74 --- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 9e78e21..1f2a9b6 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -62,6 +62,22 @@ void virtio_scsi_free_req(VirtIOSCSIReq *req) g_free(req); } +static void virtio_scsi_aio_acquire(VirtIOSCSICommon *vs) +{ +if (vs-dataplane_started) { +assert(vs-ctx); +aio_context_acquire(vs-ctx); +} +} + +static void virtio_scsi_aio_release(VirtIOSCSICommon *vs) +{ +if (vs-dataplane_started) { +assert(vs-ctx); +aio_context_release(vs-ctx); +} +} These are not needed if you do the acquire/release in virtio_scsi_push_event. static void virtio_scsi_complete_req(VirtIOSCSIReq *req) { VirtIOSCSI *s = req-dev; @@ -69,13 +85,19 @@ static void virtio_scsi_complete_req(VirtIOSCSIReq *req) VirtIODevice *vdev = VIRTIO_DEVICE(s); qemu_iovec_from_buf(req-resp_iov, 0, req-resp, req-resp_size); -virtqueue_push(vq, req-elem, req-qsgl.size + req-resp_iov.size); +if (req-vring) { +assert(req-vq == NULL); +virtio_scsi_vring_push_notify(req); +} else { +virtqueue_push(vq, req-elem, req-qsgl.size + req-resp_iov.size); +virtio_notify(vdev, vq); +} + if (req-sreq) { req-sreq-hba_private = NULL; scsi_req_unref(req-sreq); } virtio_scsi_free_req(req); -virtio_notify(vdev, vq); } static void virtio_scsi_bad_req(void) @@ -204,10 +226,16 @@ static void *virtio_scsi_load_request(QEMUFile *f, SCSIRequest *sreq) static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) { SCSIDevice *d = virtio_scsi_device_find(s, req-req.tmf.lun); +VirtIOSCSICommon *vs = (VirtIOSCSICommon *)s; SCSIRequest *r, *next; BusChild *kid; int target; +if (vs-dataplane_started bdrv_get_aio_context(d-conf.bs) != vs-ctx) { +aio_context_acquire(vs-ctx); +bdrv_set_aio_context(d-conf.bs, vs-ctx); +aio_context_release(vs-ctx); +} /* Here VIRTIO_SCSI_S_OK means FUNCTION COMPLETE. */ req-resp.tmf.response = VIRTIO_SCSI_S_OK; @@ -344,8 +372,13 @@ void virtio_scsi_handle_ctrl_req(VirtIOSCSI *s, VirtIOSCSIReq *req) static void virtio_scsi_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) { VirtIOSCSI *s = (VirtIOSCSI *)vdev; +VirtIOSCSICommon *vs = (VirtIOSCSICommon *)vdev; VirtIOSCSIReq *req; +if (vs-ctx) { +virtio_scsi_dataplane_start(vs); +return; +} while ((req = virtio_scsi_pop_req(s, vq))) { virtio_scsi_handle_ctrl_req(s, req); } @@ -439,6 +472,11 @@ void virtio_scsi_handle_cmd_req(VirtIOSCSI *s, VirtIOSCSIReq *req) virtio_scsi_complete_cmd_req(req); return; } +if (vs-dataplane_started bdrv_get_aio_context(d-conf.bs) != vs-ctx) { +aio_context_acquire(vs-ctx); +bdrv_set_aio_context(d-conf.bs, vs-ctx); +aio_context_release(vs-ctx); +} req-sreq = scsi_req_new(d, req-req.cmd.tag, virtio_scsi_get_lun(req-req.cmd.lun), req-req.cdb, req); @@ -461,8 +499,13 @@ static void virtio_scsi_handle_cmd(VirtIODevice *vdev, VirtQueue *vq) { /* use non-QOM casts in the data path */ VirtIOSCSI *s = (VirtIOSCSI *)vdev; +VirtIOSCSICommon *vs = (VirtIOSCSICommon *)vdev; VirtIOSCSIReq *req; +if (vs-ctx) { +virtio_scsi_dataplane_start(vs); +return; +} A migration state change notifier (like in virtio-blk-dataplane) is missing. while ((req = virtio_scsi_pop_req(s, vq))) { virtio_scsi_handle_cmd_req(s, req); } @@ -513,6 +556,9 @@ static void virtio_scsi_reset(VirtIODevice *vdev) VirtIOSCSI *s = VIRTIO_SCSI(vdev); VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev); +if (vs-ctx) { +virtio_scsi_dataplane_stop(vs); +} s-resetting++; qbus_reset_all(s-bus.qbus); s-resetting--; @@ -555,7 +601,11 @@ void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev, return; } -req = virtio_scsi_pop_req(s, vs-event_vq); +if (vs-dataplane_started) { +req = virtio_scsi_pop_req_vring(s, vs-event_vring); +} else { +req = virtio_scsi_pop_req(s, vs-event_vq); +} if (!req) { s-events_dropped = true; return; @@
Re: [Qemu-devel] [RFC v2 2/3] Add units-per-idebus property
John Snow js...@redhat.com writes: Signed-off-by: John Snow js...@redhat.com --- blockdev.c| 10 -- device-hotplug.c | 2 +- hw/i386/pc_q35.c | 3 ++- include/hw/boards.h | 3 ++- include/sysemu/blockdev.h | 2 +- vl.c | 19 +++ 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/blockdev.c b/blockdev.c index 5e7c93a..6c524b7 100644 --- a/blockdev.c +++ b/blockdev.c @@ -45,6 +45,7 @@ #include qmp-commands.h #include trace.h #include sysemu/arch_init.h +#include hw/boards.h static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives); @@ -643,7 +644,7 @@ QemuOptsList qemu_legacy_drive_opts = { }, }; -DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) +DriveInfo *drive_new(QemuOpts *all_opts, MachineClass *mc) { const char *value; DriveInfo *dinfo = NULL; @@ -651,6 +652,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) QemuOpts *legacy_opts; DriveMediaType media = MEDIA_DISK; BlockInterfaceType type; +BlockInterfaceType block_default_type = mc-block_default_type; int cyls, heads, secs, translation; int max_devs, bus_id, unit_id, index; const char *devaddr; @@ -828,7 +830,11 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) unit_id = qemu_opt_get_number(legacy_opts, unit, -1); index = qemu_opt_get_number(legacy_opts, index, -1); -max_devs = if_max_devs[type]; +if (type == IF_IDE mc-units_per_idebus) { +max_devs = mc-units_per_idebus; +} else { +max_devs = if_max_devs[type]; +} This overrides if_max_devs[IF_IDE] in one out of three places. if_max_devs[type] governs the mapping between index and (bus, unit). If it's zero, then (bus, unit) = (0, index). Else, (bus, unit) = (index / max_devs, index % max_devs). Overriding it just here affects these things: * Picking a default when the user specifies neither index nor unit * Range checking unit * Default ID, but let's ignore that for now It does *not* affect drive_index_to_bus_id(), drive_index_to_unit_id(), i.e. the actual mapping between index and (bus, unit)! index=1 is still mapped to (bus, unit) = (0, 1). No good. Testing (needs an incremental fix, see below) confirms: qemu: -drive if=ide,media=cdrom,index=1: unit 1 too big (max is 0) You have to override if_max_devs[] consistently. You provide for overriding if_max_devs[IF_IDE] only. It'll do for now. if (index != -1) { if (bus_id != 0 || unit_id != -1) { diff --git a/device-hotplug.c b/device-hotplug.c index e6a1ffb..857ac53 100644 --- a/device-hotplug.c +++ b/device-hotplug.c @@ -40,7 +40,7 @@ DriveInfo *add_init_drive(const char *optstr) return NULL; mc = MACHINE_GET_CLASS(current_machine); -dinfo = drive_new(opts, mc-block_default_type); +dinfo = drive_new(opts, mc); if (!dinfo) { qemu_opts_del(opts); return NULL; diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index d4a907c..fd26fe1 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -348,7 +348,8 @@ static void pc_q35_init_1_4(MachineState *machine) #define PC_Q35_2_2_MACHINE_OPTIONS \ PC_Q35_MACHINE_OPTIONS, \ -.default_machine_opts = firmware=bios-256k.bin +.default_machine_opts = firmware=bios-256k.bin, \ +.units_per_idebus = 1 I figrue this keeps -drive if=ide for older Q35 machines compatibly broken. If that's what we want to do... static QEMUMachine pc_q35_machine_v2_2 = { PC_Q35_2_2_MACHINE_OPTIONS, diff --git a/include/hw/boards.h b/include/hw/boards.h index dfb6718..73e656f 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -37,6 +37,7 @@ struct QEMUMachine { no_cdrom:1, no_sdcard:1; int is_default; +unsigned short units_per_idebus; const char *default_machine_opts; const char *default_boot_order; GlobalProperty *compat_props; if_max_devs[] and the max_devs variables are all int. I'd rather not mix signed and unsigned without need @@ -95,11 +96,11 @@ struct MachineClass { no_cdrom:1, no_sdcard:1; int is_default; +unsigned short units_per_idebus; const char *default_machine_opts; const char *default_boot_order; GlobalProperty *compat_props; const char *hw_version; - HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev); }; Let's keep the blank line separating the instance variables from the method. diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index 25d52d2..f7de0a0 100644 --- a/include/sysemu/blockdev.h +++ b/include/sysemu/blockdev.h @@
Re: [Qemu-devel] [PATCH] block: delete cow block driver
On Tue, Sep 16, 2014 at 03:24:24PM +0100, Stefan Hajnoczi wrote: This patch removes support for the cow file format. Normally we do not break backwards compatibility but in this case there is no impact and it is the most logical option. Extraordinary claims require extraordinary evidence so I will show why removing the cow block driver is the right thing to do. The cow file format is the disk image format for Usermode Linux, a way of running a Linux system in userspace. The performance of UML was never great and it was hacky, but it enjoyed some popularity before hardware virtualization support became mainstream. QEMU's block/cow.c is supposed to read this image file format. Unfortunately the file format was underspecified: 1. Earlier Linux versions used the MAXPATHLEN constant for the backing filename field. The value of MAXPATHLEN can change, so Linux switched to a 4096 literal but QEMU has a 1024 literal. 2. Padding was not used on the header struct (both in the Linux kernel and in QEMU) so the struct layout varied across architectures. In particular, i386 and x86_64 were different due to int64_t alignment differences. Linux now uses __attribute__((packed)), QEMU does not. Therefore: 1. QEMU cow images do not conform to the Linux cow image file format. 2. cow images cannot be shared between different host architectures. This means QEMU cow images are useless and QEMU has not had bug reports from users actually hitting these issues. Let's get rid of this thing, it serves no purpose and no one will be affected. Signed-off-by: Stefan Hajnoczi stefa...@redhat.com --- block/Makefile.objs | 2 +- block/cow.c | 432 --- qapi/block-core.json | 5 +- qemu-doc.texi| 9 - qemu-img.texi| 4 +- qmp-commands.hx | 2 +- tests/image-fuzzer/runner.py | 5 +- tests/qemu-iotests/069 | 2 +- tests/qemu-iotests/072 | 2 +- tests/qemu-iotests/099 | 2 +- tests/qemu-iotests/common| 6 - ui/cocoa.m | 2 +- 12 files changed, 12 insertions(+), 461 deletions(-) delete mode 100644 block/cow.c Applied to my block tree: https://github.com/stefanha/qemu/commits/block Stefan pgpw9B3tbDOh9.pgp Description: PGP signature
Re: [Qemu-devel] [PATCH] block: vhdx - fix reading beyond pointer during image creation
On Tue, Sep 16, 2014 at 03:12:06PM -0400, Jeff Cody wrote: In vhdx_create_metadata(), we allocate 40 bytes to entry_buffer for the various metadata table entries. However, we write out 64kB from that buffer into the new file. Only write out the correct 40 bytes. Signed-off-by: Jeff Cody jc...@redhat.com --- block/vhdx.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) Thanks, applied to my block tree: https://github.com/stefanha/qemu/commits/block Stefan pgpO3SN3qDSU_.pgp Description: PGP signature
Re: [Qemu-devel] [RFC v2 3/3] ahci: implement -cdrom and -hd[a-d]
John Snow js...@redhat.com writes: Signed-off-by: John Snow js...@redhat.com --- hw/i386/pc_q35.c | 3 +++ hw/ide/ahci.c| 31 +++ hw/ide/ahci.h| 3 +++ 3 files changed, 37 insertions(+) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index fd26fe1..0f33696 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -86,6 +86,7 @@ static void pc_q35_init(MachineState *machine) DeviceState *icc_bridge; PcGuestInfo *guest_info; ram_addr_t lowmem; +DriveInfo *hd[MAX_SATA_PORTS]; /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory * and 256 Mbytes for PCI Express Enhanced Configuration Access Mapping @@ -253,6 +254,8 @@ static void pc_q35_init(MachineState *machine) true, ich9-ahci); idebus[0] = qdev_get_child_bus(ahci-qdev, ide.0); idebus[1] = qdev_get_child_bus(ahci-qdev, ide.1); +ahci_drive_get(ahci, hd); +ahci_ide_create_devs(ahci, hd); if (usb_enabled(false)) { /* Should we create 6 UHCI according to ich9 spec? */ diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index ba69de3..ae28de4 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1402,3 +1402,34 @@ static void sysbus_ahci_register_types(void) } type_init(sysbus_ahci_register_types) + +void ahci_drive_get(PCIDevice *dev, DriveInfo **tab) +{ +AHCIPCIState *d = ICH_AHCI(dev); +AHCIState *ahci = d-ahci; +unsigned i; + +if ((i = drive_get_max_bus(IF_IDE)) = ahci-ports) { I might be one of the strongest advocates for brevity on this list, but even I frown on embedding assignments in conditionals without a genuine need, and on reusing loop counters for unrelated purposes. Moreover, you're mixing signed and unsigned: drive_get_max_bus() returns int, ahci-ports is int32_t, but your i is unsigned. Breaks when drive_get_max_bus() returns -1 because no IF_IDE drives are defined: $ qemu -vnc :0 -M q35 -nodefaults AHCI: Too many IDE buses defined for AHCI (-1 5) Stick to int. int n, i; n = drive_get_max_bus(IF_IDE); if (n = ahci-ports) { +fprintf(stderr, AHCI: Too many IDE buses defined for AHCI (%d %d)\n, +i, ahci-ports - 1); +} + +for (i = 0; i ahci-ports; ++i) { Compares unsigned i with signed ahci-ports. Stick to int. +tab[i] = drive_get_by_index(IF_IDE, i); +} +} + +void ahci_ide_create_devs(PCIDevice *dev, DriveInfo **tab) +{ +AHCIPCIState *d = ICH_AHCI(dev); +AHCIState *ahci = d-ahci; +unsigned i; + +for (i = 0; i ahci-ports; i++) { Likewise. +if (tab[i] == NULL) { +continue; +} +ide_create_drive(ahci-dev[i].port, 0, tab[i]); +} + +} diff --git a/hw/ide/ahci.h b/hw/ide/ahci.h index 1543df7..06a18de 100644 --- a/hw/ide/ahci.h +++ b/hw/ide/ahci.h @@ -332,4 +332,7 @@ void ahci_uninit(AHCIState *s); void ahci_reset(AHCIState *s); +void ahci_drive_get(PCIDevice *dev, DriveInfo **tab); +void ahci_ide_create_devs(PCIDevice *dev, DriveInfo **tab); + #endif /* HW_IDE_AHCI_H */
Re: [Qemu-devel] [PATCH v2 0/9] virtio: fix virtio child recount in transports
Hi, Michael, Paolo and Markus This patch series fix an obvious resource leak issue about virtio devices. Maybe those should be merged in qemu-stable tree IMHO. But the patch serial using property_alias function which introduce a regression (-device FOO,?) such as: before: virtio-blk-pci.physical_block_size=blocksize virtio-blk-pci.logical_block_size=blocksize virtio-blk-pci.drive=drive virtio-net-pci.netdev=netdev virtio-net-pci.vlan=vlan virtio-net-pci.mac=macaddr after: virtio-blk-pci.physical_block_size=uint16 virtio-blk-pci.logical_block_size=uint16 virtio-blk-pci.drive=str virtio-net-pci.netdev=str virtio-net-pci.vlan=int32 virtio-net-pci.mac=str So, I posted a patch series: [PATCH v2 0/3] Fix confused output for alias properties which to fix the output regression. But Paolo said this fixing way is layering violation. Now, it seems that the both seriaes are stagnant. What's your opinion? Thanks a lot! Does this patch series can be merged firstly? Best regards, -Gonglei -Original Message- From: Gonglei (Arei) Sent: Tuesday, September 09, 2014 2:35 PM To: qemu-devel@nongnu.org Cc: m...@redhat.com; pbonz...@redhat.com; stefa...@redhat.com; Huangweidong (C); ag...@suse.de; Huangpeng (Peter); r...@twiddle.net; cornelia.h...@de.ibm.com; borntrae...@de.ibm.com; Luonengjun; Gonglei (Arei) Subject: [PATCH v2 0/9] virtio: fix virtio child recount in transports From: Gonglei arei.gong...@huawei.com virtio-$device-{pci, s390, ccw} all duplicate the qdev properties of their virtio child. This approach does not work well with string or pointer properties since we must be careful about leaking or double-freeing them. Use the QOM alias property to forward property accesses to the VirtIORNG child. This way no duplication is necessary. For their child, object_initialize() leaves the object with a refcount of 1. object_property_add_child() adds its own reference which is dropped again when the property is deleted. The upshot of this is that we always have a refcount = 1. Upon hot unplug the virtio-$device child is not finalized! Drop our reference after the child property has been added to the parent. The v1 as below: http://lists.gnu.org/archive/html/qemu-devel/2014-09/msg01208.html Changes since v1: 1. using alias properties avoid to double-free property.(Stefan) 2. add handling all other virtio-devices had the same probleam. 3. same handling for CCW and s390-virito. Acknowledgements: I copied Stefan's commit message about virtio-blk which summarized reasons very well, I cannot agree more with him. Holp Stefan do not mind, thank you so much! Gonglei (9): virtio-net: use aliases instead of duplicate qdev properties virtio: fix virtio-net child refcount in transports virtio/vhost scsi: use aliases instead of duplicate qdev properties virtio/vhost-scsi: fix virtio-scsi/vhost-scsi child refcount in transports virtio-serial: use aliases instead of duplicate qdev properties virtio-serial: fix virtio-serial child refcount in transports virtio-rng: use aliases instead of duplicate qdev properties virtio-rng: fix virtio-rng child refcount in transports virtio-balloon: fix virtio-balloon child refcount in transports hw/s390x/s390-virtio-bus.c | 16 ++-- hw/s390x/virtio-ccw.c | 18 +++--- hw/virtio/virtio-pci.c | 18 +++--- 3 files changed, 32 insertions(+), 20 deletions(-) -- 1.7.12.4
Re: [Qemu-devel] [RFC v2 0/3] Q35/AHCI -cdrom/-hda desugaring
John Snow js...@redhat.com writes: This is an extremely rough/quick sketch of a -cdrom/-hda desugaring fix for Q35/AHCI. Before I spent any time on it, I wanted feedback from Markus or anyone else who had concerns about how this problem would get fixed. This is, then, rough approach #2. Highlights: (1) Add a board property (instead of a HBA property, sigh) that defines how we should map (index, (bus,unit)). Imperfect, but it'll do for now. The place in the boards that sets it should point to the HBA in a comment. (2) Modify drive_new to accept the MachineClass instead of the default interface type. This does not affect how default drives get added, because any over-rides to the default type get handled in options, so while it appears we have removed the type of default drives, we have not. (3) Create helpers for AHCI to assist the Q35 board in populating the AHCI device with the IDE drives. (4) Create a helper to whine at us for oversights and help bug reporters give us more meaningful information. General approach looks good to me; I can see only coding bugs, not design flaws.
[Qemu-devel] [[PATCH v2] 1/1] vpc.c: Add VHD resize support
This patch introduces resize support for dynamic and fixed VHD images. Note that differencing VHD images do not support this operation. In order to resize dynamic VHDs, the BAT region may need to be extended. This may require moving the first data blocks, making room for it to expand. This required updating the according BAT entries for the moved blocks as well, as well as initializing the new BAT entries. In case of fixed VHDs, the only thing that needs to be done is moving and updating the footer. Note that this patch assumes that all the data blocks are written right after the BAT. Signed-off-by: Lucian Petrut lpet...@cloudbasesolutions.com --- block/vpc.c | 186 +++- 1 file changed, 184 insertions(+), 2 deletions(-) Changes from previous version: fixed a few coding style nits underlined by the checkpatch.pl script. I forgot to run this script before submiting the first version, sorry about this.diff --git a/block/vpc.c b/block/vpc.c index 055efc4..6a13574 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -417,7 +417,7 @@ static inline int64_t get_sector_offset(BlockDriverState *bs, * * Returns 0 on success and 0 on error */ -static int rewrite_footer(BlockDriverState* bs) +static int rewrite_footer(BlockDriverState *bs, bool update_header) { int ret; BDRVVPCState *s = bs-opaque; @@ -427,6 +427,13 @@ static int rewrite_footer(BlockDriverState* bs) if (ret 0) return ret; +if (update_header) { +ret = bdrv_pwrite_sync(bs-file, 0, s-footer_buf, HEADER_SIZE); +if (ret 0) { +return ret; +} +} + return 0; } @@ -466,7 +473,7 @@ static int64_t alloc_block(BlockDriverState* bs, int64_t sector_num) // Write new footer (the old one will be overwritten) s-free_data_block_offset += s-block_size + s-bitmap_size; -ret = rewrite_footer(bs); +ret = rewrite_footer(bs, false); if (ret 0) goto fail; @@ -852,6 +859,180 @@ out: return ret; } + +static int vpc_truncate(BlockDriverState *bs, int64_t offset) +{ +BDRVVPCState *s = bs-opaque; +VHDFooter *footer = (VHDFooter *) s-footer_buf; +VHDDynDiskHeader *dyndisk_header; +void *buf = NULL; +int64_t new_total_sectors, old_bat_size, new_bat_size, +block_offset, new_block_offset, bat_offset; +int32_t bat_value, data_blocks_required; +int ret = 0; +uint16_t cyls = 0; +uint8_t heads = 0; +uint8_t secs_per_cyl = 0; +uint32_t new_num_bat_entries; +uint64_t index, block_index, new_bat_right_limit; + +if (offset 511) { +error_report(The new size must be a multiple of 512.); +return -EINVAL; +} + +if (offset bs-total_sectors * 512) { +error_report(Shrinking vhd images is not supported.); +return -ENOTSUP; +} + +if (cpu_to_be32(footer-type) == VHD_DIFFERENCING) { +error_report(Resizing differencing vhd images is not supported.); +return -ENOTSUP; +} + +old_bat_size = (s-max_table_entries * 4 + 511) ~511; +new_total_sectors = offset / BDRV_SECTOR_SIZE; + +for (index = 0; new_total_sectors (int64_t)cyls * heads * secs_per_cyl; +index++) { +if (calculate_geometry(new_total_sectors + index, cyls, heads, + secs_per_cyl)) { +return -EFBIG; +} +} +new_total_sectors = (int64_t) cyls * heads * secs_per_cyl; +new_num_bat_entries = (new_total_sectors + s-block_size / 512) / + (s-block_size / 512); + +if (cpu_to_be32(footer-type) == VHD_DYNAMIC) { +new_bat_size = (new_num_bat_entries * 4 + 511) ~511; +/* Number of blocks required for extending the BAT */ +data_blocks_required = (new_bat_size - old_bat_size + +s-block_size - 1) / s-block_size; +new_bat_right_limit = s-bat_offset + old_bat_size + + data_blocks_required * + (s-block_size + s-bitmap_size); + +for (block_index = 0; block_index +data_blocks_required; block_index++){ +/* + * The BAT has to be extended. We'll have to move the first + * data block(s) to the end of the file, making room for the + * BAT to expand. Also, the BAT entries have to be updated for + * the moved blocks. + */ + +block_offset = s-bat_offset + old_bat_size + + block_index * (s-block_size + s-bitmap_size); +if (block_offset = s-free_data_block_offset) { +/* +* Do not allocate a new block for the BAT if no data blocks +* were previously allocated to the vhd image. +*/ +s-free_data_block_offset += (new_bat_size - old_bat_size); +break; +} + +if
Re: [Qemu-devel] [PATCH] block: Validate node-name
On Wed, Sep 17, 2014 at 01:31:06PM +0200, Kevin Wolf wrote: The device_name of a BlockDriverState is currently checked because it is always used as a QemuOpts ID and qemu_opts_create() checks whether such IDs are wellformed. node-name is supposed to share the same namespace, but it isn't checked currently. This patch adds explicit checks both for device_name and node-name so that the same rules will still apply even if QemuOpts won't be used any more at some point. Signed-off-by: Kevin Wolf kw...@redhat.com --- block.c | 16 +--- include/qemu/option.h | 1 + util/qemu-option.c| 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) Thanks, applied to my block tree: https://github.com/stefanha/qemu/commits/block Stefan pgp9OVo8bGnPh.pgp Description: PGP signature
Re: [Qemu-devel] [PATCH v5 0/1] async: aio_context_new(): Handle event_notifier_init failure
On Thu, Sep 18, 2014 at 02:30:48PM +0300, Chrysostomos Nanakos wrote: v4-v5 -- * Set thread_id before calling aio_context_new(). That way qmp_query_iothreads() will display thread_id -1 for a failed IOThread object than an uninitialized value. * qemu_init_main_loop() will return -EMFILE if aio_context_new() fail. The actual failure reason is placed in the propagated error message. * Initialize 'Error *local_error' value to NULL. v3-v4 -- * Remove escaped single quotes from error messages. * Rephrase commit log. v2-v3 -- * Remove errno usage and print the detailed message based on errno when event_notifier_init() fails. * Propagate error and return from iothread_complete() if aio_context_new() fails. * Return if !iothread-ctx from iothread_instance_finalize(), used by QOM when object_unref(obj) is called after user_creatable_complete() fails. * Remove cosmetic fixes accidentally introduced by editor and fix code style issues. v1-v2 -- * aio_context_new() returns NULL if the initialization of event notifier fails. * Add descriptive error messages if aio_context_new() and event_notifier_init() fail. * Fix gpollfds leak. Chrysostomos Nanakos (1): async: aio_context_new(): Handle event_notifier_init failure async.c | 16 +++- include/block/aio.h |2 +- include/qemu/main-loop.h |2 +- iothread.c | 11 ++- main-loop.c |9 +++-- qemu-img.c |8 +++- qemu-io.c|7 ++- qemu-nbd.c |6 +- tests/test-aio.c | 10 +- tests/test-thread-pool.c | 10 +- tests/test-throttle.c| 10 +- vl.c |5 +++-- 12 files changed, 78 insertions(+), 18 deletions(-) -- 1.7.10.4 Thanks, applied to my block tree: https://github.com/stefanha/qemu/commits/block Stefan pgpFsvuGE0vyZ.pgp Description: PGP signature
Re: [Qemu-devel] [PULL 13/21] apic_common: vapic_paddr synchronization fix
Hi, Paolo! From: Paolo Bonzini [mailto:paolo.bonz...@gmail.com] On Behalf Of Paolo Bonzini From: Pavel Dovgalyuk pavel.dovga...@ispras.ru This patch postpones vapic_paddr initialization, which is performed during migration. When vapic_paddr is synchronized within the migration process, apic_common functions could operate with incorrect apic state, if it hadn't loaded yet. This patch postpones the synchronization until the virtual machine is started, ensuring that the whole virtual machine state has been loaded. +static int vapic_post_load(void *opaque, int version_id) +{ +VAPICROMState *s = opaque; + /* * The old implementation of qemu-kvm did not provide the state * VAPIC_STANDBY. Reconstruct it. @@ -752,17 +776,8 @@ static int vapic_post_load(void *opaque, int version_id) return -1; } } -if (s-state == VAPIC_ACTIVE) { -if (smp_cpus == 1) { -run_on_cpu(first_cpu, do_vapic_enable, s); -} else { -zero = g_malloc0(s-rom_state.vapic_size); -cpu_physical_memory_write(s-vapic_paddr, zero, - s-rom_state.vapic_size); -g_free(zero); -} -} +s-vmsentry = qemu_add_vm_change_state_handler(kvmvapic_vm_state_change, s); return 0; I've tested this patch with replay. I enabled VM reset (which was previously disabled for replay) while loading the VM state and discovered the following problem. vapic_enable function in kvmapic.c retrieves cpu number with the get_kpcr_number() function. When cpu number is -1 vapic_enable exits and does not call apic_enable_vapic, which should setup vapic_paddr field. Without this call vapic_paddr remains initialized with default value and behavior of the virtual machine becomes different. Pavel Dovgalyuk
Re: [Qemu-devel] [PATCH 00/15] AHCI test helper refactors
John Snow js...@redhat.com writes: The original version of the AHCI test base which is now staged for being merged, processes the ahci_identify test in a monolithic fashion. In authoring new tests, it became necessary and obvious as to how the operation of this device should be factored out to ease the writing of new AHCI tests. This patch set issues the necessary refactorings to support future test development for AHCI. This patch set DOES NOT account for any new fixes and requires no fixes from my AHCI fixes RFC in order to run successfully on 2014-09-18's origin/master. This patch set does not alter the operation of the existing test, or add new tests. It only offers refactorings for future patch submissions which depend on them, but are still under consideration. [...] tests/ahci-test.c | 860 -- 1 file changed, 583 insertions(+), 277 deletions(-) Ignorant question: why should we commit the monolithic test only to refactor it extensively right away?
Re: [Qemu-devel] [PATCH v2] vmdk: Fix integer overflow in offset calculation
On 15.09.2014 04:32, Fam Zheng wrote: This fixes the bug introduced by commit c6ac36e (vmdk: Optimize cluster allocation). $ ~/build/master/qemu-io /stor/vm/arch.vmdk -c 'write 2G 1k' write failed: Invalid argument Reported-by: Mark Cave-Ayland mark.cave-ayl...@ilande.co.uk Signed-off-by: Fam Zheng f...@redhat.com --- block/vmdk.c | 2 +- tests/qemu-iotests/005 | 10 +- tests/qemu-iotests/005.out | 10 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index a1cb911..3fd7738 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1113,7 +1113,7 @@ static int get_cluster_offset(BlockDriverState *bs, uint32_t min_count, *l2_table; bool zeroed = false; int64_t ret; -int32_t cluster_sector; +int64_t cluster_sector; if (m_data) { m_data-valid = 0; diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005 index ba1236d..fc8944c 100755 --- a/tests/qemu-iotests/005 +++ b/tests/qemu-iotests/005 @@ -59,7 +59,7 @@ fi echo echo creating large image -_make_test_img 5000G +_make_test_img 16T echo echo small read @@ -69,6 +69,14 @@ echo echo small write $QEMU_IO -c write 8192 4096 $TEST_IMG | _filter_qemu_io +echo +echo small read at high offset +$QEMU_IO -c read 4T 4096 $TEST_IMG | _filter_qemu_io + +echo +echo small write at high offset +$QEMU_IO -c write 4T 4096 $TEST_IMG | _filter_qemu_io + # success, all done echo *** done rm -f $seq.full diff --git a/tests/qemu-iotests/005.out b/tests/qemu-iotests/005.out index 2d3e7df..fd6aed9 100644 --- a/tests/qemu-iotests/005.out +++ b/tests/qemu-iotests/005.out @@ -1,7 +1,7 @@ QA output created by 005 creating large image -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=536870912 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=17592186044416 small read read 4096/4096 bytes at offset 1024 @@ -10,4 +10,12 @@ read 4096/4096 bytes at offset 1024 small write wrote 4096/4096 bytes at offset 8192 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +small read at high offset +read 4096/4096 bytes at offset 4398046511104 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +small write at high offset +wrote 4096/4096 bytes at offset 4398046511104 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) *** done Okay, this test works for VMDK. However, now this test no longer works with raw, at least not on my system (ftruncate() fails). So we could either exempt raw from this test like vpc (which is probably fine since I don't see the point in trying to create such huge raw images; if it works for other image formats, that should be fine) or we (you) cannot reuse this test. In case you opt for the former (exempt raw like vpc): Reviewed-by: Max Reitz mre...@redhat.com
Re: [Qemu-devel] [PATCH v2] vmdk: Fix integer overflow in offset calculation
On 19.09.2014 13:52, Max Reitz wrote: On 15.09.2014 04:32, Fam Zheng wrote: This fixes the bug introduced by commit c6ac36e (vmdk: Optimize cluster allocation). $ ~/build/master/qemu-io /stor/vm/arch.vmdk -c 'write 2G 1k' write failed: Invalid argument Reported-by: Mark Cave-Ayland mark.cave-ayl...@ilande.co.uk Signed-off-by: Fam Zheng f...@redhat.com --- block/vmdk.c | 2 +- tests/qemu-iotests/005 | 10 +- tests/qemu-iotests/005.out | 10 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index a1cb911..3fd7738 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1113,7 +1113,7 @@ static int get_cluster_offset(BlockDriverState *bs, uint32_t min_count, *l2_table; bool zeroed = false; int64_t ret; -int32_t cluster_sector; +int64_t cluster_sector; if (m_data) { m_data-valid = 0; diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005 index ba1236d..fc8944c 100755 --- a/tests/qemu-iotests/005 +++ b/tests/qemu-iotests/005 @@ -59,7 +59,7 @@ fi echo echo creating large image -_make_test_img 5000G +_make_test_img 16T echo echo small read @@ -69,6 +69,14 @@ echo echo small write $QEMU_IO -c write 8192 4096 $TEST_IMG | _filter_qemu_io +echo +echo small read at high offset +$QEMU_IO -c read 4T 4096 $TEST_IMG | _filter_qemu_io + +echo +echo small write at high offset +$QEMU_IO -c write 4T 4096 $TEST_IMG | _filter_qemu_io + # success, all done echo *** done rm -f $seq.full diff --git a/tests/qemu-iotests/005.out b/tests/qemu-iotests/005.out index 2d3e7df..fd6aed9 100644 --- a/tests/qemu-iotests/005.out +++ b/tests/qemu-iotests/005.out @@ -1,7 +1,7 @@ QA output created by 005 creating large image -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=536870912 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=17592186044416 small read read 4096/4096 bytes at offset 1024 @@ -10,4 +10,12 @@ read 4096/4096 bytes at offset 1024 small write wrote 4096/4096 bytes at offset 8192 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +small read at high offset +read 4096/4096 bytes at offset 4398046511104 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +small write at high offset +wrote 4096/4096 bytes at offset 4398046511104 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) *** done Okay, this test works for VMDK. However, now this test no longer works with raw, at least not on my system (ftruncate() fails). So we could either exempt raw from this test like vpc (which is probably fine since I don't see the point in trying to create such huge raw images; if it works for other image formats, that should be fine) or we (you) cannot reuse this test. Oh, I forgot to add: I only tested qcow2, vmdk and raw; so there might be other image formats which no longer work with this test. I'm completely fine with excluding all of them from this, because failure to pass it would then be format-specific and no longer a general problem of the block layer (which this generic test is probably for). Max In case you opt for the former (exempt raw like vpc): Reviewed-by: Max Reitz mre...@redhat.com
[Qemu-devel] [RFC patch 3/6] vfio: make vfio build on s390
From: Frank Blaschka frank.blasc...@de.ibm.com This patch adds some small changes to make vfio build on s390. Signed-off-by: Frank Blaschka frank.blasc...@de.ibm.com --- drivers/vfio/Kconfig |2 +- drivers/vfio/pci/vfio_pci_rdwr.c |8 2 files changed, 9 insertions(+), 1 deletion(-) --- a/drivers/vfio/Kconfig +++ b/drivers/vfio/Kconfig @@ -16,7 +16,7 @@ config VFIO_SPAPR_EEH menuconfig VFIO tristate VFIO Non-Privileged userspace driver framework depends on IOMMU_API - select VFIO_IOMMU_TYPE1 if X86 + select VFIO_IOMMU_TYPE1 if (X86 || S390) select VFIO_IOMMU_SPAPR_TCE if (PPC_POWERNV || PPC_PSERIES) select VFIO_SPAPR_EEH if (PPC_POWERNV || PPC_PSERIES) select ANON_INODES --- a/drivers/vfio/pci/vfio_pci_rdwr.c +++ b/drivers/vfio/pci/vfio_pci_rdwr.c @@ -177,6 +177,13 @@ ssize_t vfio_pci_bar_rw(struct vfio_pci_ return done; } +#ifdef CONFIG_NO_IOPORT_MAP +ssize_t vfio_pci_vga_rw(struct vfio_pci_device *vdev, char __user *buf, + size_t count, loff_t *ppos, bool iswrite) +{ + return -EINVAL; +} +#else ssize_t vfio_pci_vga_rw(struct vfio_pci_device *vdev, char __user *buf, size_t count, loff_t *ppos, bool iswrite) { @@ -236,3 +243,4 @@ ssize_t vfio_pci_vga_rw(struct vfio_pci_ return done; } +#endif
[Qemu-devel] [RFC patch 1/6] KVM: s390: Enable PCI instructions
Enable PCI instructions for s390 KVM. Signed-off-by: Frank Blaschka frank.blasc...@de.ibm.com --- arch/s390/kvm/kvm-s390.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -1787,7 +1787,7 @@ static int __init kvm_s390_init(void) } memcpy(vfacilities, S390_lowcore.stfle_fac_list, 16); vfacilities[0] = 0xff82fff3f4fc2000UL; - vfacilities[1] = 0x005cUL; + vfacilities[1] = 0x07dcUL; return 0; }
[Qemu-devel] [RFC patch 0/6] vfio based pci pass-through for qemu/KVM on s390
This set of patches implements a vfio based solution for pci pass-through on the s390 platform. The kernel stuff is pretty much straight forward, but qemu needs more work. Most interesting patch is: vfio: make vfio run on s390 platform I hope Alex Alex can give me some guidance how to do the changes in an appropriate way. After creating a separate iommmu address space for each attached PCI device I can successfully run the vfio type1 iommu. So If we could extend type1 not registering all guest memory (see patch) I think we do not need a special vfio iommu for s390 for the moment. The patches implement the base pass-through support. s390 specific virtualization functions are currently not included. This would be a second step after the base support is done. kernel patches apply to linux-kvm-next KVM: s390: Enable PCI instructions iommu: add iommu for s390 platform vfio: make vfio build on s390 qemu patches apply to qemu-master s390: Add PCI bus support s390: implement pci instruction vfio: make vfio run on s390 platform Thx for feedback and review comments Frank
[Qemu-devel] [RFC patch 5/6] s390: implement pci instruction
From: Frank Blaschka frank.blasc...@de.ibm.com This patch implements the s390 pci instructions in qemu. This allows to attach qemu pci devices including vfio. This does not mean the devices are functional but at least detection and config/memory space access is working. Signed-off-by: Frank Blaschka frank.blasc...@de.ibm.com --- target-s390x/Makefile.objs |2 target-s390x/kvm.c | 52 +++ target-s390x/pci_ic.c | 621 + target-s390x/pci_ic.h | 425 ++ 4 files changed, 1099 insertions(+), 1 deletion(-) --- a/target-s390x/Makefile.objs +++ b/target-s390x/Makefile.objs @@ -2,4 +2,4 @@ obj-y += translate.o helper.o cpu.o inte obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o obj-y += gdbstub.o obj-$(CONFIG_SOFTMMU) += ioinst.o arch_dump.o -obj-$(CONFIG_KVM) += kvm.o +obj-$(CONFIG_KVM) += kvm.o pci_ic.o --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -40,6 +40,7 @@ #include exec/gdbstub.h #include trace.h #include qapi-event.h +#include pci_ic.h /* #define DEBUG_KVM */ @@ -56,6 +57,7 @@ #define IPA0_B2 0xb200 #define IPA0_B9 0xb900 #define IPA0_EB 0xeb00 +#define IPA0_E3 0xe300 #define PRIV_B2_SCLP_CALL 0x20 #define PRIV_B2_CSCH0x30 @@ -76,8 +78,17 @@ #define PRIV_B2_XSCH0x76 #define PRIV_EB_SQBS0x8a +#define PRIV_EB_PCISTB 0xd0 +#define PRIV_EB_SIC 0xd1 #define PRIV_B9_EQBS0x9c +#define PRIV_B9_CLP 0xa0 +#define PRIV_B9_PCISTG 0xd0 +#define PRIV_B9_PCILG 0xd2 +#define PRIV_B9_RPCIT 0xd3 + +#define PRIV_E3_MPCIFC 0xd0 +#define PRIV_E3_STPCIFC 0xd4 #define DIAG_IPL0x308 #define DIAG_KVM_HYPERCALL 0x500 @@ -813,6 +824,18 @@ static int handle_b9(S390CPU *cpu, struc int r = 0; switch (ipa1) { +case PRIV_B9_CLP: +r = kvm_clp_service_call(cpu, run); +break; +case PRIV_B9_PCISTG: +r = kvm_pcistg_service_call(cpu, run); +break; +case PRIV_B9_PCILG: +r = kvm_pcilg_service_call(cpu, run); +break; +case PRIV_B9_RPCIT: +r = kvm_rpcit_service_call(cpu, run); +break; case PRIV_B9_EQBS: /* just inject exception */ r = -1; @@ -831,6 +854,12 @@ static int handle_eb(S390CPU *cpu, struc int r = 0; switch (ipa1) { +case PRIV_EB_PCISTB: +r = kvm_pcistb_service_call(cpu, run); +break; +case PRIV_EB_SIC: +r = kvm_sic_service_call(cpu, run); +break; case PRIV_EB_SQBS: /* just inject exception */ r = -1; @@ -844,6 +873,26 @@ static int handle_eb(S390CPU *cpu, struc return r; } +static int handle_e3(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1) +{ +int r = 0; + +switch (ipa1) { +case PRIV_E3_MPCIFC: +r = kvm_mpcifc_service_call(cpu, run); +break; +case PRIV_E3_STPCIFC: +r = kvm_stpcifc_service_call(cpu, run); +break; +default: +r = -1; +DPRINTF(KVM: unhandled PRIV: 0xe3%x\n, ipa1); +break; +} + +return r; +} + static int handle_hypercall(S390CPU *cpu, struct kvm_run *run) { CPUS390XState *env = cpu-env; @@ -1038,6 +1087,9 @@ static int handle_instruction(S390CPU *c case IPA0_EB: r = handle_eb(cpu, run, ipa1); break; +case IPA0_E3: +r = handle_e3(cpu, run, run-s390_sieic.ipb 0xff); +break; case IPA0_DIAG: r = handle_diag(cpu, run, run-s390_sieic.ipb); break; --- /dev/null +++ b/target-s390x/pci_ic.c @@ -0,0 +1,621 @@ +/* + * s390 PCI intercepts + * + * Copyright 2014 IBM Corp. + * Author(s): Frank Blaschka frank.blasc...@de.ibm.com + *Hong Bo Li lih...@cn.ibm.com + *Yi Min Zhao zyi...@cn.ibm.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ + +#include sys/types.h +#include sys/ioctl.h +#include sys/mman.h + +#include linux/kvm.h +#include asm/ptrace.h +#include hw/pci/pci.h +#include hw/pci/pci_host.h +#include net/net.h + +#include qemu-common.h +#include qemu/timer.h +#include migration/qemu-file.h +#include sysemu/sysemu.h +#include sysemu/kvm.h +#include cpu.h +#include sysemu/device_tree.h +#include monitor/monitor.h +#include pci_ic.h + +#include hw/hw.h +#include hw/pci/pci.h +#include hw/pci/pci_bridge.h +#include hw/pci/pci_bus.h +#include hw/pci/pci_host.h +#include hw/s390x/s390-pci-bus.h +#include exec/exec-all.h + +/* #define DEBUG_S390PCI_IC */ +#ifdef DEBUG_S390PCI_IC +#define DPRINTF(fmt, ...) \ +
[Qemu-devel] [RFC patch 2/6] iommu: add iommu for s390 platform
From: Frank Blaschka frank.blasc...@de.ibm.com Add a basic iommu for the s390 platform. The code is pretty simple since on s390 each PCI device has its own virtual io address space starting at the same vio address. For this a domain could hold only one pci device. Also there is no relation between pci devices so each device belongs to a separate iommu group. Signed-off-by: Frank Blaschka frank.blasc...@de.ibm.com --- arch/s390/include/asm/pci.h |3 arch/s390/pci/pci_dma.c | 21 - drivers/iommu/Kconfig |9 ++ drivers/iommu/Makefile |1 drivers/iommu/s390-iommu.c | 181 5 files changed, 213 insertions(+), 2 deletions(-) --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -177,6 +177,9 @@ struct zpci_dev *get_zdev_by_fid(u32); /* DMA */ int zpci_dma_init(void); void zpci_dma_exit(void); +int dma_update_trans(struct zpci_dev *zdev, unsigned long pa, +dma_addr_t dma_addr, size_t size, int flags); +void dma_purge_rto_entries(struct zpci_dev *zdev); /* FMB */ int zpci_fmb_enable_device(struct zpci_dev *); --- a/arch/s390/pci/pci_dma.c +++ b/arch/s390/pci/pci_dma.c @@ -139,8 +139,8 @@ static void dma_update_cpu_trans(struct entry_clr_protected(entry); } -static int dma_update_trans(struct zpci_dev *zdev, unsigned long pa, - dma_addr_t dma_addr, size_t size, int flags) +int dma_update_trans(struct zpci_dev *zdev, unsigned long pa, +dma_addr_t dma_addr, size_t size, int flags) { unsigned int nr_pages = PAGE_ALIGN(size) PAGE_SHIFT; u8 *page_addr = (u8 *) (pa PAGE_MASK); @@ -180,6 +180,7 @@ no_refresh: spin_unlock_irqrestore(zdev-dma_table_lock, irq_flags); return rc; } +EXPORT_SYMBOL_GPL(dma_update_trans); static void dma_free_seg_table(unsigned long entry) { @@ -210,6 +211,22 @@ static void dma_cleanup_tables(struct zp zdev-dma_table = NULL; } +void dma_purge_rto_entries(struct zpci_dev *zdev) +{ + unsigned long *table; + int rtx; + + if (!zdev || !zdev-dma_table) + return; + table = zdev-dma_table; + for (rtx = 0; rtx ZPCI_TABLE_ENTRIES; rtx++) + if (reg_entry_isvalid(table[rtx])) { + dma_free_seg_table(table[rtx]); + invalidate_table_entry(table[rtx]); + } +} +EXPORT_SYMBOL_GPL(dma_purge_rto_entries); + static unsigned long __dma_alloc_iommu(struct zpci_dev *zdev, unsigned long start, int size) { --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -302,4 +302,13 @@ config ARM_SMMU Say Y here if your SoC includes an IOMMU device implementing the ARM SMMU architecture. +config S390_IOMMU +bool s390 IOMMU Support +depends on S390 +select IOMMU_API +help + Support for the IBM s/390 IOMMU + + If unsure, say N here. + endif # IOMMU_SUPPORT --- a/drivers/iommu/Makefile +++ b/drivers/iommu/Makefile @@ -19,3 +19,4 @@ obj-$(CONFIG_EXYNOS_IOMMU) += exynos-iom obj-$(CONFIG_SHMOBILE_IOMMU) += shmobile-iommu.o obj-$(CONFIG_SHMOBILE_IPMMU) += shmobile-ipmmu.o obj-$(CONFIG_FSL_PAMU) += fsl_pamu.o fsl_pamu_domain.o +obj-$(CONFIG_S390_IOMMU) += s390-iommu.o --- /dev/null +++ b/drivers/iommu/s390-iommu.c @@ -0,0 +1,181 @@ +#include linux/io.h +#include linux/interrupt.h +#include linux/platform_device.h +#include linux/slab.h +#include linux/pm_runtime.h +#include linux/clk.h +#include linux/err.h +#include linux/mm.h +#include linux/iommu.h +#include linux/errno.h +#include linux/list.h +#include linux/memblock.h +#include linux/export.h +#include linux/pci.h +#include linux/sizes.h +#include asm/pci_dma.h + +#define S390_IOMMU_PGSIZES SZ_4K + +struct s390_domain { + struct zpci_dev *zdev; +}; + +static int s390_iommu_domain_init(struct iommu_domain *domain) +{ + struct s390_domain *priv; + + priv = kzalloc(sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + domain-priv = priv; + return 0; +} + +static void s390_iommu_domain_destroy(struct iommu_domain *domain) +{ + kfree(domain-priv); + domain-priv = NULL; +} + +static int s390_iommu_attach_device(struct iommu_domain *domain, + struct device *dev) +{ + struct s390_domain *priv = domain-priv; + + if (priv-zdev) + return -EEXIST; + + priv-zdev = (struct zpci_dev *)to_pci_dev(dev)-sysdata; + return 0; +} + +static void s390_iommu_detach_device(struct iommu_domain *domain, +struct device *dev) +{ + struct s390_domain *priv = domain-priv; + + dma_purge_rto_entries(priv-zdev); + priv-zdev = NULL; +} + +static int s390_iommu_map(struct iommu_domain *domain, unsigned long iova, +
[Qemu-devel] [RFC patch 6/6] vfio: make vfio run on s390 platform
From: Frank Blaschka frank.blasc...@de.ibm.com Following changes are made because of platform differences: 1) s390 does not support mmap'ing of PCI BARs so we have to go via slow path 2) no intx support 3) no classic MSIX interrupts. The pci hw understands the concept of requesting MSIX irqs but irqs are delivered as s390 adapter irqs. Introduce s390 specific functions for msix notification (slow path) and msi routes (kvm fast path). 4) Use type1 iommu but register only for iommu address space Signed-off-by: Frank Blaschka frank.blasc...@de.ibm.com --- hw/misc/vfio.c | 24 1 file changed, 24 insertions(+) --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -40,6 +40,9 @@ #include sysemu/kvm.h #include sysemu/sysemu.h #include hw/misc/vfio.h +#ifdef TARGET_S390X +#include hw/s390x/s390-pci-bus.h +#endif /* #define DEBUG_VFIO */ #ifdef DEBUG_VFIO @@ -51,7 +54,11 @@ #endif /* Extra debugging, trap acceleration paths for more logging */ +#ifdef TARGET_S390X +#define VFIO_ALLOW_MMAP 0 +#else #define VFIO_ALLOW_MMAP 1 +#endif #define VFIO_ALLOW_KVM_INTX 1 #define VFIO_ALLOW_KVM_MSI 1 #define VFIO_ALLOW_KVM_MSIX 1 @@ -554,6 +561,10 @@ static int vfio_enable_intx(VFIODevice * struct vfio_irq_set *irq_set; int32_t *pfd; +#ifdef TARGET_S390X +return 0; +#endif + if (!pin) { return 0; } @@ -664,7 +675,11 @@ static void vfio_msi_interrupt(void *opa #endif if (vdev-interrupt == VFIO_INT_MSIX) { +#ifdef TARGET_S390X +s390_msix_notify(vdev-pdev, nr); +#else msix_notify(vdev-pdev, nr); +#endif } else if (vdev-interrupt == VFIO_INT_MSI) { msi_notify(vdev-pdev, nr); } else { @@ -730,7 +745,11 @@ static void vfio_add_kvm_msi_virq(VFIOMS return; } +#ifdef TARGET_S390X +virq = s390_irqchip_add_msi_route(vector-vdev-pdev, kvm_state, *msg); +#else virq = kvm_irqchip_add_msi_route(kvm_state, *msg); +#endif if (virq 0) { event_notifier_cleanup(vector-kvm_interrupt); return; @@ -3702,8 +3721,13 @@ static int vfio_connect_container(VFIOGr container-iommu_data.type1.listener = vfio_memory_listener; container-iommu_data.release = vfio_listener_release; +#ifdef TARGET_S390X +memory_listener_register(container-iommu_data.type1.listener, + container-space-as); +#else memory_listener_register(container-iommu_data.type1.listener, address_space_memory); +#endif if (container-iommu_data.type1.error) { ret = container-iommu_data.type1.error;
Re: [Qemu-devel] [PULL 13/21] apic_common: vapic_paddr synchronization fix
Il 19/09/2014 12:43, Pavel Dovgaluk ha scritto: I've tested this patch with replay. I enabled VM reset (which was previously disabled for replay) while loading the VM state and discovered the following problem. vapic_enable function in kvmapic.c retrieves cpu number with the get_kpcr_number() function. When cpu number is -1 vapic_enable exits and does not call apic_enable_vapic, which should setup vapic_paddr field. Without this call vapic_paddr remains initialized with default value and behavior of the virtual machine becomes different. IIUC the fix would be to move part of vapic_enable out to its separate function, and call it from do_vapic_enable? Could you prepare a patch? Paolo
[Qemu-devel] [RFC patch 4/6] s390: Add PCI bus support
From: Frank Blaschka frank.blasc...@de.ibm.com This patch implements a pci bus for s390x together with some infrastructure to generate and handle hotplug events. It also provides device configuration/unconfiguration via sclp instruction interception. Signed-off-by: Frank Blaschka frank.blasc...@de.ibm.com --- default-configs/s390x-softmmu.mak |1 hw/s390x/Makefile.objs|1 hw/s390x/css.c|5 hw/s390x/css.h|1 hw/s390x/s390-pci-bus.c | 404 ++ hw/s390x/s390-pci-bus.h | 166 +++ hw/s390x/s390-virtio-ccw.c|2 hw/s390x/sclp.c | 10 include/hw/s390x/sclp.h |8 target-s390x/ioinst.c | 52 target-s390x/ioinst.h |1 11 files changed, 650 insertions(+), 1 deletion(-) --- a/default-configs/s390x-softmmu.mak +++ b/default-configs/s390x-softmmu.mak @@ -1,3 +1,4 @@ +include pci.mak CONFIG_VIRTIO=y CONFIG_SCLPCONSOLE=y CONFIG_S390_FLIC=y --- a/hw/s390x/Makefile.objs +++ b/hw/s390x/Makefile.objs @@ -8,3 +8,4 @@ obj-y += ipl.o obj-y += css.o obj-y += s390-virtio-ccw.o obj-y += virtio-ccw.o +obj-$(CONFIG_KVM) += s390-pci-bus.o --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1281,6 +1281,11 @@ void css_generate_chp_crws(uint8_t cssid /* TODO */ } +void css_generate_css_crws(uint8_t cssid) +{ +css_queue_crw(CRW_RSC_CSS, 0, 0, 0); +} + int css_enable_mcsse(void) { trace_css_enable_facility(mcsse); --- a/hw/s390x/css.h +++ b/hw/s390x/css.h @@ -99,6 +99,7 @@ void css_queue_crw(uint8_t rsc, uint8_t void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid, int hotplugged, int add); void css_generate_chp_crws(uint8_t cssid, uint8_t chpid); +void css_generate_css_crws(uint8_t cssid); void css_adapter_interrupt(uint8_t isc); #define CSS_IO_ADAPTER_VIRTIO 1 --- /dev/null +++ b/hw/s390x/s390-pci-bus.c @@ -0,0 +1,404 @@ +/* + * s390 PCI BUS + * + * Copyright 2014 IBM Corp. + * Author(s): Frank Blaschka frank.blasc...@de.ibm.com + *Hong Bo Li lih...@cn.ibm.com + *Yi Min Zhao zyi...@cn.ibm.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ + +#include hw/pci/pci.h +#include hw/s390x/css.h +#include hw/s390x/sclp.h +#include hw/pci/msi.h +#include qemu/error-report.h +#include s390-pci-bus.h + +/* #define DEBUG_S390PCI_BUS */ +#ifdef DEBUG_S390PCI_BUS +#define DPRINTF(fmt, ...) \ +do { fprintf(stderr, S390pci-bus: fmt, ## __VA_ARGS__); } while (0) +#else +#define DPRINTF(fmt, ...) \ +do { } while (0) +#endif + +static const unsigned long be_to_le = BITS_PER_LONG - 1; +static QTAILQ_HEAD(, SeiContainer) pending_sei = +QTAILQ_HEAD_INITIALIZER(pending_sei); +static QTAILQ_HEAD(, S390PCIBusDevice) device_list = +QTAILQ_HEAD_INITIALIZER(device_list); + +int chsc_sei_nt2_get_event(void *res) +{ +ChscSeiNt2Res *nt2_res = (ChscSeiNt2Res *)res; +PciCcdfAvail *accdf; +PciCcdfErr *eccdf; +int rc = 1; +SeiContainer *sei_cont; + +sei_cont = QTAILQ_FIRST(pending_sei); +if (sei_cont) { +QTAILQ_REMOVE(pending_sei, sei_cont, link); +nt2_res-nt = 2; +nt2_res-cc = sei_cont-cc; +switch (sei_cont-cc) { +case 1: /* error event */ +eccdf = (PciCcdfErr *)nt2_res-ccdf; +eccdf-fid = cpu_to_be32(sei_cont-fid); +eccdf-fh = cpu_to_be32(sei_cont-fh); +break; +case 2: /* availability event */ +accdf = (PciCcdfAvail *)nt2_res-ccdf; +accdf-fid = cpu_to_be32(sei_cont-fid); +accdf-fh = cpu_to_be32(sei_cont-fh); +accdf-pec = cpu_to_be16(sei_cont-pec); +break; +default: +abort(); +} +g_free(sei_cont); +rc = 0; +} + +return rc; +} + +int chsc_sei_nt2_have_event(void) +{ +return !QTAILQ_EMPTY(pending_sei); +} + +static S390PCIBusDevice *s390_pci_find_dev_by_fid(uint32_t fid) +{ +S390PCIBusDevice *pbdev; + +QTAILQ_FOREACH(pbdev, device_list, next) { +if (pbdev-fid == fid) { +return pbdev; +} +} +return NULL; +} + +void s390_pci_sclp_configure(int configure, SCCB *sccb) +{ +PciCfgSccb *psccb = (PciCfgSccb *)sccb; +S390PCIBusDevice *pbdev = s390_pci_find_dev_by_fid(be32_to_cpu(psccb-aid)); +uint16_t rc; + +if (pbdev) { +if ((configure == 1 pbdev-configured == true) || +(configure == 0 pbdev-configured == false)) { +rc = SCLP_RC_NO_ACTION_REQUIRED; +} else { +pbdev-configured = !pbdev-configured; +rc = SCLP_RC_NORMAL_COMPLETION; +} +} else { +DPRINTF(sclp config %d no dev found\n, configure); +rc =
Re: [Qemu-devel] [PATCH 1/2] pc-dimm: No numa option shouldn't break hotplug memory feature
On Wed, 17 Sep 2014 16:32:20 +0800 Hu Tao hu...@cn.fujitsu.com wrote: On Tue, Sep 16, 2014 at 06:39:15PM +0800, zhanghailiang wrote: If we do not configure numa option, memory hotplug should work as well. It should not depend on numa option. Steps to reproduce: (1) Start VM: qemu-kvm -m 1024,slots=4,maxmem=8G (2) Hotplug memory It will fail and reports: 'DIMM property node has value 0' which exceeds the number of numa nodes: 0 I rememberd Tang Chen had a patch for this bug, this is what Andrey suggested: I thnk that there should be no cases when dimm is plugged (and check from patch is fired up) without actually populated NUMA, because not every OS will workaround this by faking the node. This doesn't take in to account that dimm device by itself has nothing to do with numa (numa is just optional property of its representation in ACPI land and nothing else). In case initial memory is converted to dimm devices, qemu can be started without numa option and it still must work. So I'm in favor of this path. https://lists.nongnu.org/archive/html/qemu-devel/2014-08/msg04587.html Have you tested this patch with Windows guest? Regards, Hu
Re: [Qemu-devel] [PATCH 1/2] pc-dimm: No numa option shouldn't break hotplug memory feature
On Tue, 16 Sep 2014 18:39:15 +0800 zhanghailiang zhang.zhanghaili...@huawei.com wrote: If we do not configure numa option, memory hotplug should work as well. It should not depend on numa option. Steps to reproduce: (1) Start VM: qemu-kvm -m 1024,slots=4,maxmem=8G (2) Hotplug memory It will fail and reports: 'DIMM property node has value 0' which exceeds the number of numa nodes: 0 Signed-off-by: zhanghailiang zhang.zhanghaili...@huawei.com --- hw/mem/pc-dimm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 5bfc5b7..a800ea7 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -252,7 +252,7 @@ static void pc_dimm_realize(DeviceState *dev, Error **errp) error_setg(errp, ' PC_DIMM_MEMDEV_PROP ' property is not set); return; } -if (dimm-node = nb_numa_nodes) { +if ((nb_numa_nodes 0) (dimm-node = nb_numa_nodes)) { error_setg(errp, 'DIMM property PC_DIMM_NODE_PROP has value % PRIu32 ' which exceeds the number of numa nodes: %d, dimm-node, nb_numa_nodes); Reviewed-By: Igor Mammedov imamm...@redhat.com
Re: [Qemu-devel] [PATCH v3 0/3] block: Always compile virtio-blk dataplane
On Wed, Sep 10, 2014 at 02:17:48PM +0800, Fam Zheng wrote: v3: Fix -ENOBUFS. v2: Import virtio_vring.h. Fam Zheng (3): virtio: Import virtio_vring.h vring: Better error handling if num is too large block: Always compile virtio-blk dataplane configure | 21 + hw/block/Makefile.objs | 2 +- hw/block/virtio-blk.c | 20 + hw/net/vhost_net.c | 2 +- hw/virtio/Makefile.objs | 2 +- hw/virtio/dataplane/vring.c | 3 +- include/hw/virtio/dataplane/vring.h | 2 +- include/hw/virtio/virtio-blk.h | 2 - include/hw/virtio/virtio_ring.h | 167 linux-headers/linux/vhost.h | 2 +- 10 files changed, 178 insertions(+), 45 deletions(-) create mode 100644 include/hw/virtio/virtio_ring.h -- 1.9.3 Thanks, applied to my block tree: https://github.com/stefanha/qemu/commits/block Stefan pgpSyNxRnSfxi.pgp Description: PGP signature
Re: [Qemu-devel] [PATCH 00/15] AHCI test helper refactors
On Fri, Sep 19, 2014 at 12:53:22PM +0200, Markus Armbruster wrote: John Snow js...@redhat.com writes: The original version of the AHCI test base which is now staged for being merged, processes the ahci_identify test in a monolithic fashion. In authoring new tests, it became necessary and obvious as to how the operation of this device should be factored out to ease the writing of new AHCI tests. This patch set issues the necessary refactorings to support future test development for AHCI. This patch set DOES NOT account for any new fixes and requires no fixes from my AHCI fixes RFC in order to run successfully on 2014-09-18's origin/master. This patch set does not alter the operation of the existing test, or add new tests. It only offers refactorings for future patch submissions which depend on them, but are still under consideration. [...] tests/ahci-test.c | 860 -- 1 file changed, 583 insertions(+), 277 deletions(-) Ignorant question: why should we commit the monolithic test only to refactor it extensively right away? The patches merged in the block tree have been fully reviewed and tested. It took a long time to reach that state. I don't want to go back to square one and have to re-review it all. Refactoring is mechanical and therefore easy to review. The earliest we can merge this new series is next week. Let's not try to make it perfect if that means building up a monster series over many weeks. Let's merge incrementally and keep moving. (I do believe that clean commit history is important and patches should be polished, but in this case work spans too long to keep redoing it all.) Stefan pgpDpNHsNiKtZ.pgp Description: PGP signature
Re: [Qemu-devel] [PATCH 1/2] serial: reset state at startup
Il 19/09/2014 11:17, Chen, Tiejun ha scritto: On 2014/9/19 16:54, Paolo Bonzini wrote: When a serial port is started, its initial state is all zero. Make it consistent with reset state instead. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/char/serial.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/char/serial.c b/hw/char/serial.c index 764e184..4523ccb 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -668,6 +668,7 @@ void serial_realize_core(SerialState *s, Error **errp) serial_event, s); It should just follow qemu_register_reset(serial_reset, s). fifo8_create(s-recv_fifo, UART_FIFO_LENGTH); fifo8_create(s-xmit_fifo, UART_FIFO_LENGTH); +serial_reset(s); Or at least we should push this before this pair of fifo8_create() since No, it should be _after_ the fifo8_create() pair. With the current implementation it doesn't matter, but first you create something and then you initialize it, not the other way round. Paolo static void serial_reset(void *opaque) { ... fifo8_reset(s-recv_fifo); fifo8_reset(s-xmit_fifo); Thanks Tiejun } void serial_exit_core(SerialState *s)
Re: [Qemu-devel] [PULL 13/21] apic_common: vapic_paddr synchronization fix
From: Paolo Bonzini [mailto:paolo.bonz...@gmail.com] On Behalf Of Paolo Bonzini Il 19/09/2014 12:43, Pavel Dovgaluk ha scritto: I've tested this patch with replay. I enabled VM reset (which was previously disabled for replay) while loading the VM state and discovered the following problem. vapic_enable function in kvmapic.c retrieves cpu number with the get_kpcr_number() function. When cpu number is -1 vapic_enable exits and does not call apic_enable_vapic, which should setup vapic_paddr field. Without this call vapic_paddr remains initialized with default value and behavior of the virtual machine becomes different. IIUC the fix would be to move part of vapic_enable out to its separate function, and call it from do_vapic_enable? Could you prepare a patch? static int vapic_enable(VAPICROMState *s, X86CPU *cpu) { int cpu_number = get_kpcr_number(cpu); hwaddr vapic_paddr; static const uint8_t enabled = 1; if (cpu_number 0) { return -1; } vapic_paddr = s-vapic_paddr + (((hwaddr)cpu_number) VAPIC_CPU_SHIFT); cpu_physical_memory_write(vapic_paddr + offsetof(VAPICState, enabled), enabled, sizeof(enabled)); apic_enable_vapic(cpu-apic_state, vapic_paddr); s-state = VAPIC_ACTIVE; return 0; } vapic_paddr depends on cpu_number. cpu_number cannot be retrieved when do_vapic_enable executes. Thus we cannot reconstruct vapic_paddr in that function. Pavel Dovgalyuk
Re: [Qemu-devel] [PATCH 0/6] pc: bring ACPI table size below to 2.0 levels, try fixing -initrd for good
Il 19/09/2014 09:36, Gerd Hoffmann ha scritto: Hi, However, there is another problem. As the ACPI tables grow, we need to move the address at which linuxboot.bin loads the initrd. This address is placed close to the end of memory, but it is QEMU that tells linuxboot.bin where exactly the initrd is to be loaded. And QEMU cannot really know how much high memory SeaBIOS will use, because QEMU does not know the final e820 memory map. The solution would be to let linuxboot.bin parse the memory map and ignore the suggested initrd base address, but that's tedious. In the meanwhile, we can just assume that most of the need comes from the ACPI tables (which is in fact true: patch 3 adds a fixed 32k extra just in case) and dynamically resize the padding. Hmm. That assumes we are running seabios, where we know how much memory we actually need. IMHO we should either really parse the memory map, or reserve more space. IIRC it doesn't matter that much where we load the initrd. It should not be just after the kernel, because the kernel needs some space to unpack itself and for early allocations such as initial page tables. This is where the common practice to load the initrd high comes from. But whenever we leave 128k or 16m between initrd and top-of-memory doesn't make much of a difference. Ok, I wrote the e820 scanning code, and it works with KVM but it hits a TCG bug. The rep/movsb in SeaBIOS's e820 routine just doesn't write to es:di. The TCG ops seem sane: set_label $0x1 ext16u_i64 tmp2,rsi ld_i64 tmp3,env,$0x108 // load ds base add_i64 tmp2,tmp2,tmp3 ext32u_i64 tmp2,tmp2 qemu_ld_i64 tmp0,tmp2,ub,$0x2 // load into tmp0 ext16u_i64 tmp2,rdi ld_i64 tmp3,env,$0xc0 // load es base add_i64 tmp2,tmp2,tmp3 ext32u_i64 tmp2,tmp2 qemu_st_i64 tmp0,tmp2,ub,$0x2 // store from tmp0 ld32s_i64 tmp0,env,$0xac// increase rsi/rdi add_i64 tmp3,rsi,tmp0 deposit_i64 rsi,rsi,tmp3,$0x0,$0x10 add_i64 tmp3,rdi,tmp0 deposit_i64 rdi,rdi,tmp3,$0x0,$0x10 movi_i64 tmp13,$0x // decrement rcx add_i64 tmp3,rcx,tmp13 deposit_i64 rcx,rcx,tmp3,$0x0,$0x10 goto_tb $0x0 movi_i64 tmp3,$0xf7b4 st_i64 tmp3,env,$0x80 exit_tb $0x7fe8a2c167a0 set_label $0x0 exit_tb $0x7fe8a2c167a3 For now I'm giving up, here is the patch just in case. It also fails with 2.1.1. There is some debugging output that goes to the serial port. With KVM it prints 1/2/2/1/2/2, while with TCG it prints 0/0/0/0/0 (it should print 1/2/2/1/2 instead). diff --git a/pc-bios/optionrom/linuxboot.S b/pc-bios/optionrom/linuxboot.S index 748c831..e6f1be1 100644 --- a/pc-bios/optionrom/linuxboot.S +++ b/pc-bios/optionrom/linuxboot.S @@ -76,6 +76,96 @@ boot_kernel: copy_kernel: + push%ds + pop %es + + /* Compute initrd address */ + mov $0xe801, %ax + xor %cx, %cx + xor %dx, %dx + int $0x15 + + /* Output could be in AX/BX or CX/DX */ + or %cx, %cx + jnz 1f + or %dx, %dx + jnz 1f + mov %ax, %cx + mov %bx, %dx +1: + + or %dx, %dx + jnz 2f + addw$1024, %cx/* add 1 MB */ + movzwl %cx, %ebp + shll$10, %ebp /* convert to bytes */ + jmp mmap_loop_start + +2: + addw$16777216 16, %dx /* add 16 MB */ + movzwl %dx, %ebp + shll$16, %ebp /* convert to bytes */ + + /* EBP (end of memory) is a hint to the loop below, that computes the + final location using the e820 memory map. O(n^2) loop, but e820 + is small anyway. */ + +mmap_loop_start: + movl%ebp, %esi/* ESI = end of memory */ + + read_fw FW_CFG_INITRD_SIZE + subl%eax, %ebp/* EBP = start of initrd */ + andl$-4096, %ebp + + xor %ebx, %ebx + + /* now move it further down according to the indications of the e820 + memory map... */ +mmap_loop: + mov $0xe820, %ax + mov $0x534D4150, %edx + mov $24, %ecx + mov $e820, %edi + int $0x15 + jc mmap_done /* if at end of list, we're done */ + cmp $0x534D4150, %eax /* if BIOS broken, exit */ + jnz mmap_done + or %ebx, %ebx/* another check for end of list */ + jz mmap_done + +mov 16(%di), %al +mov $0x3f8, %dx +add $0x30, %al +out %al, %dx +mov $0xd, %al +out %al, %dx +mov $0xa, %al +out %al, %dx + + jcxzmmap_loop /* ignore empty entries */ +
Re: [Qemu-devel] [PATCH] virtio-balloon: Fix ballooning not working correctly when hotplug memory
On Mon, 15 Sep 2014 20:29:38 +0800 zhanghailiang zhang.zhanghaili...@huawei.com wrote: When do memory balloon, it references the ram_size as the real ram size of VM, But here ram_size is not include the hotplugged memory, and the result will be confused. Steps to reproduce: (1)Start VM: qemu -m size=1024,slots=4,maxmem=8G (2)In VM: #free -m : 1024M (3)qmp balloon 512M (4)In VM: #free -m : 512M (5)hotplug pc-dimm 1G (6)In VM: #free -m : 1512M (7)qmp balloon 256M (8)In VM: #free -m :1256M Here we add a new global variable 'vm_ram_size', it will stat qmp balloon is not performance critical code and instead of a global variable, size could be calculated each time by enumerating present memory devices. the VM's real ram size which include configured ram and hotplugged ram. virtio-balloon will reference this parameter. I know it's not supported yet but what will happen with balloonig if dimm device is removed without telling about it to balloon first? I'm not sure if balloon and native memory hotplug should be integrated. Native memory hotplug was intended as a replacement for ballooning without its drawbacks albeit guest OS memory unplug support is in its infancy stage yet. Signed-off-by: zhanghailiang zhang.zhanghaili...@huawei.com --- hw/i386/pc.c | 1 + hw/virtio/virtio-balloon.c | 10 +- include/exec/cpu-common.h | 1 + vl.c | 3 +++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index b6c9b61..817810b 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1606,6 +1606,7 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev, memory_region_add_subregion(pcms-hotplug_memory, addr - pcms-hotplug_memory_base, mr); vmstate_register_ram(mr, dev); +vm_ram_size += memory_region_size(mr); hhc = HOTPLUG_HANDLER_GET_CLASS(pcms-acpi_dev); hhc-plug(HOTPLUG_HANDLER(pcms-acpi_dev), dev, local_err); diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 2c30b3d..205e1fe 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -292,7 +292,7 @@ static void virtio_balloon_set_config(VirtIODevice *vdev, memcpy(config, config_data, sizeof(struct virtio_balloon_config)); dev-actual = le32_to_cpu(config.actual); if (dev-actual != oldactual) { -qapi_event_send_balloon_change(ram_size - +qapi_event_send_balloon_change(vm_ram_size - ((ram_addr_t) dev-actual VIRTIO_BALLOON_PFN_SHIFT), error_abort); } @@ -307,7 +307,7 @@ static uint32_t virtio_balloon_get_features(VirtIODevice *vdev, uint32_t f) static void virtio_balloon_stat(void *opaque, BalloonInfo *info) { VirtIOBalloon *dev = opaque; -info-actual = ram_size - ((uint64_t) dev-actual +info-actual = vm_ram_size - ((uint64_t) dev-actual VIRTIO_BALLOON_PFN_SHIFT); } @@ -316,11 +316,11 @@ static void virtio_balloon_to_target(void *opaque, ram_addr_t target) VirtIOBalloon *dev = VIRTIO_BALLOON(opaque); VirtIODevice *vdev = VIRTIO_DEVICE(dev); -if (target ram_size) { -target = ram_size; +if (target vm_ram_size) { +target = vm_ram_size; } if (target) { -dev-num_pages = (ram_size - target) VIRTIO_BALLOON_PFN_SHIFT; +dev-num_pages = (vm_ram_size - target) VIRTIO_BALLOON_PFN_SHIFT; virtio_notify_config(vdev); } } diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index e3ec4c8..f55db6a 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -46,6 +46,7 @@ typedef uintptr_t ram_addr_t; #endif extern ram_addr_t ram_size; +extern ram_addr_t vm_ram_size; /* memory API */ diff --git a/vl.c b/vl.c index 9c9acf5..5d20d0c 100644 --- a/vl.c +++ b/vl.c @@ -132,6 +132,7 @@ DisplayType display_type = DT_DEFAULT; static int display_remote; const char* keyboard_layout = NULL; ram_addr_t ram_size; +ram_addr_t vm_ram_size; /* ram_size + hotplugged ram size */ const char *mem_path = NULL; int mem_prealloc = 0; /* force preallocation of physical target memory */ int nb_nics; @@ -3015,6 +3016,7 @@ int main(int argc, char **argv, char **envp) machine_class = find_default_machine(); cpu_model = NULL; ram_size = default_ram_size; +vm_ram_size = ram_size; snapshot = 0; cyls = heads = secs = 0; translation = BIOS_ATA_TRANSLATION_AUTO; @@ -3388,6 +3390,7 @@ int main(int argc, char **argv, char **envp) '%s' option\n, slots_str ? maxmem : slots); exit(EXIT_FAILURE); } +vm_ram_size = ram_size; break; } #ifdef CONFIG_TPM
Re: [Qemu-devel] [Spice-devel] screen freezed for 2-3 minutes on spice connect on xen windows 7 domU's with qxl after save/restore
Il 12/09/2014 16:46, Fabio Fantoni ha scritto: Il 08/07/2014 12:34, Fabio Fantoni ha scritto: Il 08/07/2014 12:06, Fabio Fantoni ha scritto: Il 08/07/2014 10:53, David Jaša ha scritto: Hi, On Út, 2014-07-08 at 10:13 +0200, Fabio Fantoni wrote: On xen 4.5 (tried with qemu 2.0.0/2.1-rc0, spice 0.12.5 and client with spice-gtk 0.23/0.25) windows 7 domUs with qxl vga works good as kvm except for one problem after xl save/restore, when after restore on spice client connect the domU's screen freezed for 2-3 minutes (and seems also windows), after this time seems that all return to works correctly. This problem happen also if spice client connect long time after restore. With stdvga not have this problem but stdvga has many missed resolutions and bad refresh performance. If you need more tests/informations tell me and I'll post them. Client and server logs would certainly help. Please run: * virt-viewer with --spice-debug option * spice-server with SPICE_DEBUG_LEVEL environment variable set to 4 or 5 (if you use qemu+libvirt, use qemu:env element: http://libvirt.org/drvqemu.html#qemucommand ) and note the location in the logs where the freeze takes place. Regards, David Thanks for your reply, in attachments: - domU's xl cfg: W7.cfg - xl -vvv create/save/restore: xen logs.txt - remote-viewer with --spice-debug after domU's start until xl save: spicelog-1.txt (zipped) - remote-viewer with --spice-debug after domU's xl restore: spicelog-2.txt Sorry for my forgetfulness, here also qemu's log: - after domU's start until xl save: qemu-dm-W7.log.1 - after domU's xl restore: qemu-dm-W7.log If you need more tests/informations tell me and I'll post them. Thanks for any reply and sorry for my bad english. ___ Spice-devel mailing list spice-de...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel The problem persist, this time I saw these in xl dmesg after restore: (XEN) HVM2 restore: CPU 0 (XEN) HVM2 restore: CPU 1 (XEN) HVM2 restore: PIC 0 (XEN) HVM2 restore: PIC 1 (XEN) HVM2 restore: IOAPIC 0 (XEN) HVM2 restore: LAPIC 0 (XEN) HVM2 restore: LAPIC 1 (XEN) HVM2 restore: LAPIC_REGS 0 (XEN) HVM2 restore: LAPIC_REGS 1 (XEN) HVM2 restore: PCI_IRQ 0 (XEN) HVM2 restore: ISA_IRQ 0 (XEN) HVM2 restore: PCI_LINK 0 (XEN) HVM2 restore: PIT 0 (XEN) HVM2 restore: RTC 0 (XEN) HVM2 restore: HPET 0 (XEN) HVM2 restore: PMTIMER 0 (XEN) HVM2 restore: MTRR 0 (XEN) HVM2 restore: MTRR 1 (XEN) HVM2 restore: VIRIDIAN_DOMAIN 0 (XEN) HVM2 restore: VIRIDIAN_VCPU 0 (XEN) HVM2 restore: VIRIDIAN_VCPU 1 (XEN) HVM2 restore: VMCE_VCPU 0 (XEN) HVM2 restore: VMCE_VCPU 1 (XEN) HVM2 restore: TSC_ADJUST 0 (XEN) HVM2 restore: TSC_ADJUST 1 (XEN) memory.c:216:d2v0 Domain 2 page number 77579 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 7757a invalid (XEN) memory.c:216:d2v0 Domain 2 page number 7757b invalid (XEN) memory.c:216:d2v0 Domain 2 page number 7757c invalid (XEN) memory.c:216:d2v0 Domain 2 page number 7757d invalid (XEN) memory.c:216:d2v0 Domain 2 page number 7757e invalid (XEN) memory.c:216:d2v0 Domain 2 page number 7757f invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77580 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77581 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77582 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77583 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77584 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77585 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77586 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77587 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77588 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77589 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 7758a invalid (XEN) memory.c:216:d2v0 Domain 2 page number 7758b invalid (XEN) memory.c:216:d2v0 Domain 2 page number 7758c invalid (XEN) memory.c:216:d2v0 Domain 2 page number 7758d invalid (XEN) memory.c:216:d2v0 Domain 2 page number 7758e invalid (XEN) memory.c:216:d2v0 Domain 2 page number 7758f invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77590 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77591 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77592 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77593 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77594 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77595 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77596 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77597 invalid (XEN) memory.c:216:d2v0 Domain 2 page number 77598 invalid (XEN) grant_table.c:1272:d2v0 Expanding dom (2) grant table from (4) to (32) frames. (XEN) irq.c:380: Dom2 callback via changed to GSI 24 Tested on latest staging (commit 7d203b337fb2dcd148d2df850e25b67c792d4d0b) plus the spice patches: https://github.com/Fantu/Xen/commits/rebase/m2r-staging If you need more informations or tests tell me and I'll post
Re: [Qemu-devel] [PATCH] block: Validate node-name
On Wed, Sep 17, 2014 at 01:31:06PM +0200, Kevin Wolf wrote: The device_name of a BlockDriverState is currently checked because it is always used as a QemuOpts ID and qemu_opts_create() checks whether such IDs are wellformed. node-name is supposed to share the same namespace, but it isn't checked currently. This patch adds explicit checks both for device_name and node-name so that the same rules will still apply even if QemuOpts won't be used any more at some point. Signed-off-by: Kevin Wolf kw...@redhat.com --- block.c | 16 +--- include/qemu/option.h | 1 + util/qemu-option.c| 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) This patch breaks qemu-iotests 048 and 055. Please fix and resend, I have dropped it from the block branch: 048 3s ... - output mismatch (see 048.out.bad) --- /home/stefanha/qemu/tests/qemu-iotests/048.out 2014-09-16 16:37:56.617967668 +0100 +++ 048.out.bad 2014-09-19 14:19:44.428753385 +0100 @@ -9,25 +9,31 @@ 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 4096/4096 bytes at offset 536576 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Images are identical. -0 -0 +qemu-img: Invalid device name +./048: line 39: 11542 Aborted (core dumped) $QEMU_IMG compare $@ $TEST_IMG ${TEST_IMG2} +134 +qemu-img: Invalid device name +./048: line 39: 11547 Aborted (core dumped) $QEMU_IMG compare $@ $TEST_IMG ${TEST_IMG2} +134 Image resized. -Warning: Image size mismatch! -Images are identical. -0 -Strict mode: Image size mismatch! -1 +qemu-img: Invalid device name +./048: line 39: 11551 Aborted (core dumped) $QEMU_IMG compare $@ $TEST_IMG ${TEST_IMG2} +134 +qemu-img: Invalid device name +./048: line 39: 11553 Aborted (core dumped) $QEMU_IMG compare $@ $TEST_IMG ${TEST_IMG2} +134 === IO: pattern 67 wrote 4096/4096 bytes at offset 1228800 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Content mismatch at offset 1228800! -1 +qemu-img: Invalid device name +./048: line 39: 11563 Aborted (core dumped) $QEMU_IMG compare $@ $TEST_IMG ${TEST_IMG2} +134 === IO: pattern 123 wrote 4096/4096 bytes at offset 0 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Content mismatch at offset 0! -1 +qemu-img: Invalid device name +./048: line 39: 11573 Aborted (core dumped) $QEMU_IMG compare $@ $TEST_IMG ${TEST_IMG2} +134 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 === IO: pattern 100 wrote 512/512 bytes at offset 0 @@ -35,6 +41,7 @@ === IO: pattern 101 wrote 512/512 bytes at offset 512 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Content mismatch at offset 512! -1 +qemu-img: Invalid device name +./048: line 39: 11596 Aborted (core dumped) $QEMU_IMG compare $@ $TEST_IMG ${TEST_IMG2} +134 Cleanup 055 9s ... [failed, exit status 1] - output mismatch (see 055.out.bad) --- /home/stefanha/qemu/tests/qemu-iotests/055.out 2014-03-14 08:29:48.818442477 + +++ 055.out.bad 2014-09-19 14:19:51.739791191 +0100 @@ -1,5 +1,23 @@ -.. +qemu-img: Invalid device name +qemu-img: Invalid device name +...F.F +== +FAIL: test_pause (__main__.TestSingleDrive) +-- +Traceback (most recent call last): + File 055, line 90, in test_pause +'target image does not match source after backup') +AssertionError: target image does not match source after backup + +== +FAIL: test_pause (__main__.TestSingleTransaction) +-- +Traceback (most recent call last): + File 055, line 252, in test_pause +'target image does not match source after backup') +AssertionError: target image does not match source after backup + -- Ran 14 tests -OK +FAILED (failures=2) Failures: 048 055 Failed 2 of 2 tests pgpkyVLNaGGFH.pgp Description: PGP signature
[Qemu-devel] [PULL 00/01] Adding new syscalls to seccomp whitelist
The following changes since commit 10e11f4d2bf171f99c6b13883a510acfbc5dd585: Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2014-09-18 20:02:01 +0100) are available in the git repository at: git://github.com/otubo/qemu.git tags/goto-upstream for you to fetch changes up to 021db05e6cb0683b12779ff519c7d857620c9e8f: seccomp: whitelist syscalls fallocate(), fadvise64(), inotify_init1() and inotify_add_watch() (2014-09-19 14:32:46 +0200) Adding new syscalls to seccomp whitelist: fallocate(), fadvise64(), inotify_init1() and inotify_add_watch(). Philipp Gesang (1): seccomp: whitelist syscalls fallocate(), fadvise64(), inotify_init1() and inotify_add_watch() qemu-seccomp.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) -- 1.9.1
[Qemu-devel] [PULL 01/01] seccomp: whitelist syscalls fallocate(), fadvise64(), inotify_init1() and inotify_add_watch()
From: Philipp Gesang philipp.ges...@intra2net.com fallocate() is needed for snapshotting. If it isn’t whitelisted $ qemu-img create -f qcow2 x.qcow 1G Formatting 'x.qcow', fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 lazy_refcounts=off $ qemu-kvm -display none -monitor stdio -sandbox on x.qcow QEMU 2.1.50 monitor - type 'help' for more information (qemu) savevm foo (qemu) loadvm foo will fail, as will subsequent savevm commands on the same image. fadvise64(), inotify_init1(), inotify_add_watch() are needed by the SDL display. Without the whitelist entries, qemu-kvm -sandbox on fails immediately. In my tests fadvise64() is called 50--51 times per VM run. That number seems independent of the duration of the run. fallocate(), inotify_init1(), inotify_add_watch() are called once each. Accordingly, they are added to the whitelist at a very low priority. Signed-off-by: Philipp Gesang philipp.ges...@intra2net.com Signed-off-by: Eduardo Otubo eduardo.ot...@profitbricks.com --- qemu-seccomp.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qemu-seccomp.c b/qemu-seccomp.c index 0503764..af6a375 100644 --- a/qemu-seccomp.c +++ b/qemu-seccomp.c @@ -231,7 +231,11 @@ static const struct QemuSeccompSyscall seccomp_whitelist[] = { { SCMP_SYS(shmctl), 240 }, { SCMP_SYS(mlock), 240 }, { SCMP_SYS(munlock), 240 }, -{ SCMP_SYS(semctl), 240 } +{ SCMP_SYS(semctl), 240 }, +{ SCMP_SYS(fallocate), 240 }, +{ SCMP_SYS(fadvise64), 240 }, +{ SCMP_SYS(inotify_init1), 240 }, +{ SCMP_SYS(inotify_add_watch), 240 } }; int seccomp_start(void) -- 1.9.1
Re: [Qemu-devel] [PATCH] Fix cross compilation (nm command)
Il 18/09/2014 22:07, Peter Maydell ha scritto: On 18 September 2014 12:55, Stefan Weil s...@weilnetz.de wrote: Commit c261d774fb9093d00e0938a19f502fb220f62718 added one more binutils tool: nm also needs a cross prefix. Signed-off-by: Stefan Weil s...@weilnetz.de Heh, completely missed that when reviewing the original patch. Reviewed-by: Peter Maydell peter.mayd...@linaro.org Are you going to apply directly? Paolo
Re: [Qemu-devel] [PATCH v4] Add HMP command info memory-devices
On Thu, 18 Sep 2014 16:09:32 +0800 zhugh zhugh.f...@cn.fujitsu.com wrote: Hi, Could anyone help to review this patch? If there was no problem, could help to merge it? thanks! zhu On Mon, 2014-09-15 at 19:31 +0800, Zhu Guihua wrote: Provides HMP equivalent of QMP query-memory-devices command. Signed-off-by: Zhu Guihua zhugh.f...@cn.fujitsu.com --- Changes since v3: - optimize the time to print memory devices' information. - change output format of di-addr and di-size. Changes since v2: - print address in hex. - change the loop control from while to for. - modify some variables' name. - optimize the time to print memory devices' kind. Changes since v1: - fix bug that accessing info-dimm when MemoryDeviceInfo is not PCDIMMDevice. - use enum to replace dimm, and lookup typename in MemoryDeviceInfoKind_lookup[] instead of opencodding it. hmp-commands.hx | 2 ++ hmp.c | 38 ++ hmp.h | 1 + monitor.c | 7 +++ 4 files changed, 48 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index f859f8d..0b1a4f7 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1778,6 +1778,8 @@ show qdev device model list show roms @item info tpm show the TPM device +@item info memory-devices +show the memory devices @end table ETEXI diff --git a/hmp.c b/hmp.c index 40a90da..feefeb4 100644 --- a/hmp.c +++ b/hmp.c @@ -1718,3 +1718,41 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict) qapi_free_MemdevList(memdev_list); } + +void hmp_info_memory_devices(Monitor *mon, const QDict *qdict) +{ +Error *err = NULL; +MemoryDeviceInfoList *info_list = qmp_query_memory_devices(err); +MemoryDeviceInfoList *info; +MemoryDeviceInfo *value; +PCDIMMDeviceInfo *di; + +for (info = info_list; info; info = info-next) { +value = info-value; + +if (value) { +switch (value-kind) { +case MEMORY_DEVICE_INFO_KIND_DIMM: +di = value-dimm; + +monitor_printf(mon, Memory device [%s]: %s\n, + MemoryDeviceInfoKind_lookup[value-kind], + di-id); 'id' might be null, here is what user will see: Memory device [dimm]: (null) I'd suggest to replace (null) with as it is done elsewhere. With that fixed Reviewed-By: Igor Mammedov imamm...@redhat.com +monitor_printf(mon, addr: 0x% PRIx64 \n, di-addr); +monitor_printf(mon, slot: % PRId64 \n, di-slot); +monitor_printf(mon, node: % PRId64 \n, di-node); +monitor_printf(mon, size: % PRIu64 \n, di-size); +monitor_printf(mon, memdev: %s\n, di-memdev); +monitor_printf(mon, hotplugged: %s\n, + di-hotplugged ? true : false); +monitor_printf(mon, hotpluggable: %s\n, + di-hotpluggable ? true : false); +break; +default: +break; +} +} +} + +qapi_free_MemoryDeviceInfoList(info_list); +} diff --git a/hmp.h b/hmp.h index 4fd3c4a..4bb5dca 100644 --- a/hmp.h +++ b/hmp.h @@ -94,6 +94,7 @@ void hmp_cpu_add(Monitor *mon, const QDict *qdict); void hmp_object_add(Monitor *mon, const QDict *qdict); void hmp_object_del(Monitor *mon, const QDict *qdict); void hmp_info_memdev(Monitor *mon, const QDict *qdict); +void hmp_info_memory_devices(Monitor *mon, const QDict *qdict); void object_add_completion(ReadLineState *rs, int nb_args, const char *str); void object_del_completion(ReadLineState *rs, int nb_args, const char *str); void device_add_completion(ReadLineState *rs, int nb_args, const char *str); diff --git a/monitor.c b/monitor.c index 34cee74..fe88e0d 100644 --- a/monitor.c +++ b/monitor.c @@ -2921,6 +2921,13 @@ static mon_cmd_t info_cmds[] = { .mhandler.cmd = hmp_info_memdev, }, { +.name = memory-devices, +.args_type = , +.params = , +.help = show memory devices, +.mhandler.cmd = hmp_info_memory_devices, +}, +{ .name = NULL, }, };
Re: [Qemu-devel] [PATCH 08/14] ppc: introduce gen_op_mfcr/gen_op_mtcr
Il 18/09/2014 23:38, Richard Henderson ha scritto: On 09/15/2014 08:03 AM, Paolo Bonzini wrote: +static inline void gen_op_mfcr(TCGv_i32 dest, int first_cr, int shift) +{ +tcg_gen_shli_i32(dest, cpu_crf[first_cr 2], shift); +} + +static inline void gen_op_mtcr(int first_cr, TCGv_i32 src, int shift) +{ +if (shift) { +tcg_gen_shri_i32(cpu_crf[first_cr 2], src, shift); +tcg_gen_andi_i32(cpu_crf[first_cr 2], cpu_crf[first_cr 2], 0x0F); +} else { +tcg_gen_andi_i32(cpu_crf[first_cr 2], src, 0x0F); +} +} Continuing on the name nit-picking, these *are* the mfocr and mtocr operations. Ok, will swap. Paolo
Re: [Qemu-devel] [PATCH 4/4] block: avoid creating oversized writes in multiwrite_merge
Il 19/09/2014 00:56, Peter Lieven ha scritto: So I think if we treat it just as a hint for multiwrite, we can avoid writing code to split oversized requests. They always worked so far, we can certainly wait until we have a real bug fix. I would not treat this as a hint. I would use it in cases where we definitely know an absolute hard limit for I/O request size. Otherwise the value for bs-bl.max_transfer_length should be 0. If there comes in an oversized request we fail it as early as possible That's the part that I'd rather not touch, at least not without doing request splitting. Paolo and regarding the multi write code we avoid that it accidentally generates an oversized request.
Re: [Qemu-devel] [question] virtio-blk performance degradationhappened with virito-serial
Il 19/09/2014 07:53, Fam Zheng ha scritto: Any ideas? The obvious, but hardish one is to switch to epoll (one epoll fd per AioContext, plus one for iohandler.c). This would require converting iohandler.c to a GSource. Paolo
Re: [Qemu-devel] [PULL 13/21] apic_common: vapic_paddr synchronization fix
Il 19/09/2014 14:50, Pavel Dovgaluk ha scritto: vapic_paddr depends on cpu_number. cpu_number cannot be retrieved when do_vapic_enable executes. Thus we cannot reconstruct vapic_paddr in that function. cpu_number will always be zero, because do_vapic_enable is only executed for smp_cpus == 1. Paolo