Re: [Qemu-devel] [PATCH 4/6] Endian fixes for virtfs
On Fri, 24 Feb 2012 11:23:30 +1100, David Gibson da...@gibson.dropbear.id.au wrote: From: Benjamin Herrenschmidt b...@kernel.crashing.org This patch fixes several endian bugs in virtfs. Cc: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Signed-off-by: Benjamin Herrenschmidt b...@kernel.crashing.org Signed-off-by: David Gibson da...@gibson.dropbear.id.au --- hw/9pfs/virtio-9p.c |8 +--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index a72ffc3..c633fb9 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -1349,7 +1349,9 @@ static void v9fs_open(void *opaque) if (s-proto_version == V9FS_PROTO_2000L) { err = pdu_unmarshal(pdu, offset, dd, fid, mode); } else { -err = pdu_unmarshal(pdu, offset, db, fid, mode); +uint8_t modebyte; +err = pdu_unmarshal(pdu, offset, db, fid, modebyte); +mode = modebyte; } if (err 0) { goto out_nofid; @@ -3260,9 +3262,9 @@ void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq) ptr = pdu-elem.out_sg[0].iov_base; -memcpy(pdu-size, ptr, 4); +pdu-size = le32_to_cpu(*(uint32_t *)ptr); pdu-id = ptr[4]; -memcpy(pdu-tag, ptr + 5, 2); +pdu-tag = le16_to_cpu(*(uint16_t *)(ptr + 5)); qemu_co_queue_init(pdu-complete); submit_pdu(s, pdu); } Reviewed-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com -aneesh
Re: [Qemu-devel] Core dumps - commit a0abe474d587499a1553372c1692811f81fd3eda
On 24 February 2012 05:49, Gerhard Wiesinger li...@wiesinger.com wrote: I'm getting coredumps: #0 qemu_opt_find (opts=0x0, name=0x7f18e8c833db kernel) at qemu-option.c:535 535 QTAILQ_FOREACH_REVERSE(opt, opts-head, QemuOptHead, next) { Yeah, I posted a fix for this on Tuesday: http://patchwork.ozlabs.org/patch/142548/ Sorry for the inconvenience. -- PMM
Re: [Qemu-devel] [PATCH v4 14/18] virtio-scsi: process control queue requests
On 02/24/2012 08:54 AM, Hu Tao wrote: should be req-req.tmf-lun here and elsewhere in this function? Yes, good catch! Paolo
[Qemu-devel] [Bug 939995] Re: v1.0-1172-g235fe3b crashes (opts=0x0)
This is fixed by http://patchwork.ozlabs.org/patch/142548/ (which hasn't been applied yet but hopefully will be soon). -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/939995 Title: v1.0-1172-g235fe3b crashes (opts=0x0) Status in QEMU: New Bug description: C:\msys\home\User\qemu\i386-softmmugdb --args qemu-system-i386.exe -L ..\pc-bios GNU gdb (GDB) 7.3 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type show copying and show warranty for details. This GDB was configured as mingw32. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from C:\msys\home\User\qemu\i386-softmmu/qemu-system-i386.exe... done. (gdb) r Starting program: C:\msys\home\User\qemu\i386-softmmu/qemu-system-i386.exe -L ..\\pc-bios [New Thread 4724.0x1224] Program received signal SIGSEGV, Segmentation fault. 0x004eeda6 in qemu_opt_get (opts=0x0, name=0x68a7c3 kernel) at qemu-option.c:545 545 QemuOpt *opt = qemu_opt_find(opts, name); (gdb) bt #0 0x004eeda6 in qemu_opt_get (opts=0x0, name=0x68a7c3 kernel) at qemu-option.c:545 #1 0x004c7166 in qemu_main (argc=3, argv=0x3e5200, envp=0x0) at C:/msys/home/User/qemu/vl.c:3250 #2 0x004c906a in SDL_main (argc=3, argv=0x3e5200) at C:/msys/home/User/qemu/vl.c:102 #3 0x0061dcf4 in console_main () #4 0x0061ddb4 in WinMain@16 () #5 0x006329fb in main () (gdb) To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/939995/+subscriptions
Re: [Qemu-devel] [PATCH 1/4] Use getaddrinfo for migration
Am 10.02.2012 07:27, schrieb Amos Kong: This allows us to use ipv4/ipv6 for migration addresses. Once there, it also uses /etc/services names (it came free). Signed-off-by: Juan Quintela quint...@redhat.com Signed-off-by: Amos Kong ak...@redhat.com --- migration-tcp.c | 60 --- net.c | 108 +++ qemu_socket.h |3 ++ 3 files changed, 127 insertions(+), 44 deletions(-) This patch is making too many changes at once: 1. Move code around 2. Remove duplicated code between client and server 3. Replace parse_host_port() with an open-coded version 4. Modify the open-coded parse_host_port() to use getaddrinfo instead of inet_aton/gethostbyname (Why can't we just change parse_host_port? Are there valid reasons to use the old implementation? Which?) This makes it rather hard to review. diff --git a/migration-tcp.c b/migration-tcp.c index 35a5781..644bb8f 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -81,43 +81,27 @@ static void tcp_wait_for_connect(void *opaque) int tcp_start_outgoing_migration(MigrationState *s, const char *host_port) { -struct sockaddr_in addr; int ret; - -ret = parse_host_port(addr, host_port); -if (ret 0) { -return ret; -} +int fd; s-get_error = socket_errno; s-write = socket_write; s-close = tcp_close; -s-fd = qemu_socket(PF_INET, SOCK_STREAM, 0); -if (s-fd == -1) { -DPRINTF(Unable to open socket); -return -socket_error(); -} - -socket_set_nonblock(s-fd); - -do { -ret = connect(s-fd, (struct sockaddr *)addr, sizeof(addr)); -if (ret == -1) { -ret = -socket_error(); -} -if (ret == -EINPROGRESS || ret == -EWOULDBLOCK) { -qemu_set_fd_handler2(s-fd, NULL, NULL, tcp_wait_for_connect, s); -return 0; -} -} while (ret == -EINTR); - -if (ret 0) { +ret = tcp_client_start(host_port, fd); +s-fd = fd; +if (ret == -EINPROGRESS || ret == -EWOULDBLOCK) { +DPRINTF(connect in progress); +qemu_set_fd_handler2(s-fd, NULL, NULL, tcp_wait_for_connect, s); +} else if (ret 0) { DPRINTF(connect failed\n); -migrate_fd_error(s); +if (ret != -EINVAL) { +migrate_fd_error(s); +} This looks odd. It is probably needed to keep the old behaviour where a failed parse_host_port() wouldn't call migrate_fd_error(). Is this really required? Maybe I'm missing something, but the caller can't know which failure case we had and if migrate_fd_error() has been called. return ret; +} else { +migrate_fd_connect(s); } -migrate_fd_connect(s); return 0; } @@ -157,28 +141,16 @@ out2: int tcp_start_incoming_migration(const char *host_port) { -struct sockaddr_in addr; -int val; +int ret; int s; DPRINTF(Attempting to start an incoming migration\n); -if (parse_host_port(addr, host_port) 0) { -fprintf(stderr, invalid host/port combination: %s\n, host_port); -return -EINVAL; -} - -s = qemu_socket(PF_INET, SOCK_STREAM, 0); -if (s == -1) { -return -socket_error(); +ret = tcp_server_start(host_port, s); +if (ret 0) { +return ret; } -val = 1; -setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)val, sizeof(val)); - -if (bind(s, (struct sockaddr *)addr, sizeof(addr)) == -1) { -goto err; -} if (listen(s, 1) == -1) { goto err; } diff --git a/net.c b/net.c index c34474f..f63014c 100644 --- a/net.c +++ b/net.c @@ -99,6 +99,114 @@ static int get_str_sep(char *buf, int buf_size, const char **pp, int sep) return 0; } +static int tcp_server_bind(int fd, struct addrinfo *rp) +{ +int ret; +int val = 1; + +/* allow fast reuse */ +setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)val, sizeof(val)); + +ret = bind(fd, rp-ai_addr, rp-ai_addrlen); + +if (ret == -1) { +ret = -socket_error(); +} +return ret; + +} + +static int tcp_client_connect(int fd, struct addrinfo *rp) +{ +int ret; + +do { +ret = connect(fd, rp-ai_addr, rp-ai_addrlen); +if (ret == -1) { +ret = -socket_error(); +} +} while (ret == -EINTR); + +return ret; +} + + +static int tcp_start_common(const char *str, int *fd, bool server) +{ +char hostname[512]; +const char *service; +const char *name; +struct addrinfo hints; +struct addrinfo *result, *rp; +int s; +int sfd; +int ret = -EINVAL; + +*fd = -1; +service = str; +if (get_str_sep(hostname, sizeof(hostname), service, ':') 0) { +return -EINVAL; +} Separating host name and port at the first colon
Re: [Qemu-devel] [Bug 939995] Re: v1.0-1172-g235fe3b crashes (opts=0x0)
2012/2/24 Peter Maydell peter.mayd...@linaro.org: This is fixed by http://patchwork.ozlabs.org/patch/142548/ (which hasn't been applied yet but hopefully will be soon). It looks like a workaround to me as if you feed NULL to qemu_opt_find() it will still crashing. -- You received this bug notification because you are subscribed to the bug report. https://bugs.launchpad.net/bugs/939995 Title: v1.0-1172-g235fe3b crashes (opts=0x0) Status in QEMU: New Bug description: C:\msys\home\User\qemu\i386-softmmugdb --args qemu-system-i386.exe -L ..\pc-bios GNU gdb (GDB) 7.3 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type show copying and show warranty for details. This GDB was configured as mingw32. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from C:\msys\home\User\qemu\i386-softmmu/qemu-system-i386.exe... done. (gdb) r Starting program: C:\msys\home\User\qemu\i386-softmmu/qemu-system-i386.exe -L ..\\pc-bios [New Thread 4724.0x1224] Program received signal SIGSEGV, Segmentation fault. 0x004eeda6 in qemu_opt_get (opts=0x0, name=0x68a7c3 kernel) at qemu-option.c:545 545 QemuOpt *opt = qemu_opt_find(opts, name); (gdb) bt #0 0x004eeda6 in qemu_opt_get (opts=0x0, name=0x68a7c3 kernel) at qemu-option.c:545 #1 0x004c7166 in qemu_main (argc=3, argv=0x3e5200, envp=0x0) at C:/msys/home/User/qemu/vl.c:3250 #2 0x004c906a in SDL_main (argc=3, argv=0x3e5200) at C:/msys/home/User/qemu/vl.c:102 #3 0x0061dcf4 in console_main () #4 0x0061ddb4 in WinMain@16 () #5 0x006329fb in main () (gdb) To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/939995/+subscriptions -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/939995 Title: v1.0-1172-g235fe3b crashes (opts=0x0) Status in QEMU: New Bug description: C:\msys\home\User\qemu\i386-softmmugdb --args qemu-system-i386.exe -L ..\pc-bios GNU gdb (GDB) 7.3 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type show copying and show warranty for details. This GDB was configured as mingw32. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from C:\msys\home\User\qemu\i386-softmmu/qemu-system-i386.exe... done. (gdb) r Starting program: C:\msys\home\User\qemu\i386-softmmu/qemu-system-i386.exe -L ..\\pc-bios [New Thread 4724.0x1224] Program received signal SIGSEGV, Segmentation fault. 0x004eeda6 in qemu_opt_get (opts=0x0, name=0x68a7c3 kernel) at qemu-option.c:545 545 QemuOpt *opt = qemu_opt_find(opts, name); (gdb) bt #0 0x004eeda6 in qemu_opt_get (opts=0x0, name=0x68a7c3 kernel) at qemu-option.c:545 #1 0x004c7166 in qemu_main (argc=3, argv=0x3e5200, envp=0x0) at C:/msys/home/User/qemu/vl.c:3250 #2 0x004c906a in SDL_main (argc=3, argv=0x3e5200) at C:/msys/home/User/qemu/vl.c:102 #3 0x0061dcf4 in console_main () #4 0x0061ddb4 in WinMain@16 () #5 0x006329fb in main () (gdb) To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/939995/+subscriptions
Re: [Qemu-devel] [PATCH 1/2] block: add the support for draining the throttled request queue
On Mon, Feb 20, 2012 at 12:50:30PM +0800, zwu.ker...@gmail.com wrote: From: Zhi Yong Wu wu...@linux.vnet.ibm.com If one guest has multiple disks with enabling I/O throttling function separately, when draining activities are done, some requests maybe are in the throttled queue; So we need to restart them at first. Moreover, when only one disk need to be drained such as hotplug out, if another disk still has some requests in its throttled queue, these request should not be effected. Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com --- block.c | 29 ++--- block_int.h |1 + 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index ae297bb..f78df78 100644 --- a/block.c +++ b/block.c @@ -853,25 +853,40 @@ void bdrv_close_all(void) } } -/* - * Wait for pending requests to complete across all BlockDriverStates - * - * This function does not flush data to disk, use bdrv_flush_all() for that - * after calling this function. - */ -void bdrv_drain_all(void) +void bdrv_drain_request(BlockDriverState *throttled_bs) { BlockDriverState *bs; +QTAILQ_FOREACH(bs, bdrv_states, list) { +if (throttled_bs throttled_bs != bs) { +continue; +} +qemu_co_queue_restart_all(bs-throttled_reqs); +} + qemu_aio_flush(); Since I/O throttling is still enabled, the restarted requests could enqueue again if they exceed the limit. We could still hit the assert. If the semantics of bdrv_drain_request() are that no requests are pending when it returns then we need a loop here. BTW bdrv_drain() would be a shorter name for this function. Stefan
Re: [Qemu-devel] [PATCH v7 00/11] XBRLE delta for live migration of large memory app
On Thu, Jan 26, 2012 at 04:24:46PM +0200, Orit Wasserman wrote: Changes from v6: 1) add assert checks to ULEB encoding/decoding 2) no need to send last zero run I took a quick look and I think the things I pointed out in previous versions have been addressed. I did not review the live migration protocol aspect of this change, maybe Anthony and/or Juan can comment. Reviewed-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
Re: [Qemu-devel] [PATCH 2/3] Allow larger return values from get_image_size()
Am 24.02.2012 01:36, schrieb David Gibson: Currently get_image_size(), used to find the size of files, returns an int. But for modern systems, int may be only 32-bit and we can have files larger than that. This patch, therefore, changes the return type of get_image_size() to off_t (the same as the return type from lseek() itself). It also audits all the callers of get_image_size() to make sure they process the new unsigned return type correctly. It's a size, so why off_t and not size_t? Andreas This leaves load_image_targphys() with a limited return type, but one thing at a time (that function has far more callers to be audited, so it will take longer to fix). Signed-off-by: David Gibson da...@gibson.dropbear.id.au -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
[Qemu-devel] Add GSoC project ideas to the wiki!
This is a reminder that QEMU will apply for Google Summer of Code 2012 and we need project ideas and mentors. Libvirt and kvm.ko projects are also welcome! http://wiki.qemu.org/Google_Summer_of_Code_2012 Please add yourself to the wiki now if you want to mentor a project this summer. I will file our application next week. Thanks, Stefan
Re: [Qemu-devel] [PATCH 1/2] block: add the support for draining the throttled request queue
On Fri, Feb 24, 2012 at 4:49 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Mon, Feb 20, 2012 at 12:50:30PM +0800, zwu.ker...@gmail.com wrote: From: Zhi Yong Wu wu...@linux.vnet.ibm.com If one guest has multiple disks with enabling I/O throttling function separately, when draining activities are done, some requests maybe are in the throttled queue; So we need to restart them at first. Moreover, when only one disk need to be drained such as hotplug out, if another disk still has some requests in its throttled queue, these request should not be effected. Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com --- block.c | 29 ++--- block_int.h | 1 + 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index ae297bb..f78df78 100644 --- a/block.c +++ b/block.c @@ -853,25 +853,40 @@ void bdrv_close_all(void) } } -/* - * Wait for pending requests to complete across all BlockDriverStates - * - * This function does not flush data to disk, use bdrv_flush_all() for that - * after calling this function. - */ -void bdrv_drain_all(void) +void bdrv_drain_request(BlockDriverState *throttled_bs) { BlockDriverState *bs; + QTAILQ_FOREACH(bs, bdrv_states, list) { + if (throttled_bs throttled_bs != bs) { + continue; + } + qemu_co_queue_restart_all(bs-throttled_reqs); + } + qemu_aio_flush(); Since I/O throttling is still enabled, the restarted requests could enqueue again if they exceed the limit. We could still hit the assert. good catch. If the semantics of bdrv_drain_request() are that no requests are pending when it returns then we need a loop here. OK. BTW bdrv_drain() would be a shorter name for this function. OK Stefan -- Regards, Zhi Yong Wu
Re: [Qemu-devel] [PATCH 2/4] net/socket: allow ipv6 for net_socket_listen_init and socket_connect_init
Am 10.02.2012 07:27, schrieb Amos Kong: Remove use of parse_host_port. More SO_SOCKADDR changes. Signed-off-by: Juan Quintela quint...@redhat.com Signed-off-by: Amos Kong ak...@redhat.com --- net/socket.c | 60 +++--- 1 files changed, 11 insertions(+), 49 deletions(-) diff --git a/net/socket.c b/net/socket.c index d4c2002..439a69c 100644 --- a/net/socket.c +++ b/net/socket.c @@ -403,29 +403,13 @@ static int net_socket_listen_init(VLANState *vlan, const char *host_str) { NetSocketListenState *s; -int fd, val, ret; -struct sockaddr_in saddr; - -if (parse_host_port(saddr, host_str) 0) -return -1; +int fd, ret; s = g_malloc0(sizeof(NetSocketListenState)); -fd = qemu_socket(PF_INET, SOCK_STREAM, 0); -if (fd 0) { -perror(socket); -g_free(s); -return -1; -} -socket_set_nonblock(fd); - -/* allow fast reuse */ -val = 1; -setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)val, sizeof(val)); - -ret = bind(fd, (struct sockaddr *)saddr, sizeof(saddr)); +ret = tcp_server_start(host_str, fd); if (ret 0) { -perror(bind); +fprintf(stderr, tcp_server_start: %s\n, strerror(ret)); error_report, and it should be strerror(-ret). g_free(s); closesocket(fd); return -1; @@ -451,41 +435,19 @@ static int net_socket_connect_init(VLANState *vlan, const char *host_str) { NetSocketState *s; -int fd, connected, ret, err; +int fd, connected, ret; struct sockaddr_in saddr; -if (parse_host_port(saddr, host_str) 0) -return -1; - -fd = qemu_socket(PF_INET, SOCK_STREAM, 0); -if (fd 0) { -perror(socket); +ret = tcp_client_start(host_str, fd); +if (ret == -EINPROGRESS || ret == -EWOULDBLOCK) { +connected = 0; +} else if (ret 0) { +closesocket(fd); There is no open fd in this case. The only time that fd != -1 and ret 0 is for -EINPROGRESS and -EWOULDBLOCK. return -1; +} else { +connected = 1; } -socket_set_nonblock(fd); -connected = 0; -for(;;) { -ret = connect(fd, (struct sockaddr *)saddr, sizeof(saddr)); -if (ret 0) { -err = socket_error(); -if (err == EINTR || err == EWOULDBLOCK) { -} else if (err == EINPROGRESS) { -break; -#ifdef _WIN32 -} else if (err == WSAEALREADY || err == WSAEINVAL) { -break; -#endif This part is lost without replacement? -} else { -perror(connect); -closesocket(fd); tcp_client_start uses close() instead of closesocket() in error case, should probably be changed. Kevin
Re: [Qemu-devel] [PATCH 1/2] block: add the support for draining the throttled request queue
On Fri, Feb 24, 2012 at 4:49 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Mon, Feb 20, 2012 at 12:50:30PM +0800, zwu.ker...@gmail.com wrote: From: Zhi Yong Wu wu...@linux.vnet.ibm.com If one guest has multiple disks with enabling I/O throttling function separately, when draining activities are done, some requests maybe are in the throttled queue; So we need to restart them at first. Moreover, when only one disk need to be drained such as hotplug out, if another disk still has some requests in its throttled queue, these request should not be effected. Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com --- block.c | 29 ++--- block_int.h | 1 + 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index ae297bb..f78df78 100644 --- a/block.c +++ b/block.c @@ -853,25 +853,40 @@ void bdrv_close_all(void) } } -/* - * Wait for pending requests to complete across all BlockDriverStates - * - * This function does not flush data to disk, use bdrv_flush_all() for that - * after calling this function. - */ -void bdrv_drain_all(void) +void bdrv_drain_request(BlockDriverState *throttled_bs) { BlockDriverState *bs; + QTAILQ_FOREACH(bs, bdrv_states, list) { + if (throttled_bs throttled_bs != bs) { + continue; + } + qemu_co_queue_restart_all(bs-throttled_reqs); + } + qemu_aio_flush(); Since I/O throttling is still enabled, the restarted requests could enqueue again if they exceed the limit. We could still hit the assert. If the semantics of bdrv_drain_request() are that no requests are pending when it returns then we need a loop here. BTW bdrv_drain() would be a shorter name for this function. For this function's semantics, i have some concerns. Is it used to drain all requests of one single disk or all disks for one guest? which is more suitable? Stefan -- Regards, Zhi Yong Wu
Re: [Qemu-devel] [PATCH 3/4] net: split hostname and service by last colon
Am 10.02.2012 07:27, schrieb Amos Kong: IPv6 address contains colons, parse will be wrong. [2312::8274]:5200 Signed-off-by: Amos Kong ak...@redhat.com --- net.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/net.c b/net.c index f63014c..9e1ef9e 100644 --- a/net.c +++ b/net.c @@ -84,7 +84,7 @@ static int get_str_sep(char *buf, int buf_size, const char **pp, int sep) const char *p, *p1; int len; p = *pp; -p1 = strchr(p, sep); +p1 = strrchr(p, sep); if (!p1) return -1; len = p1 - p; And what if the port isn't specified? I think you would erroneously interpret the last part of the IP address as port. Kevin
Re: [Qemu-devel] [PATCH 1/4] Use getaddrinfo for migration
Am 10.02.2012 07:27, schrieb Amos Kong: This allows us to use ipv4/ipv6 for migration addresses. Once there, it also uses /etc/services names (it came free). Signed-off-by: Juan Quintela quint...@redhat.com Signed-off-by: Amos Kong ak...@redhat.com --- migration-tcp.c | 60 --- net.c | 108 +++ qemu_socket.h |3 ++ 3 files changed, 127 insertions(+), 44 deletions(-) @@ -157,28 +141,16 @@ out2: int tcp_start_incoming_migration(const char *host_port) { -struct sockaddr_in addr; -int val; +int ret; int s; DPRINTF(Attempting to start an incoming migration\n); -if (parse_host_port(addr, host_port) 0) { -fprintf(stderr, invalid host/port combination: %s\n, host_port); -return -EINVAL; -} Oh, and this case doesn't print an error message any more now. Kevin
Re: [Qemu-devel] [PATCH 0/4] support to migrate with IPv6 address
Am 10.02.2012 07:26, schrieb Amos Kong: Those four patches make migration of IPv6 address work. Use getaddrinfo() to socket addresses infomation. --- Amos Kong (4): Use getaddrinfo for migration net/socket: allow ipv6 for net_socket_listen_init and socket_connect_init net: split hostname and service by last colon net: support to include ipv6 address by brackets I think it would be better to split the patches differently: 1. Create tcp_server_start by moving code. Keep using parse_host_port and the old loop around connect. 2. Unify all TCP servers to use this code 3. Introduce the client code and the convert all clients. Up to here, this should be pure refactoring work. 4. Only now start changing the logic. First thing is getaddrinfo. Don't change from IPv4 to IPv6 yet. 5. Make all changes required for IPv6 (getaddrinfo arguments, address parsing, etc.) Having step-by-step conversions with an explanation of each step in the commit message makes it so much easier to understand the commits. For the comments on details see the replies to the individual patches. Kevin
Re: [Qemu-devel] Qemu for simulating SoCs?
On Thu, Feb 23, 2012 at 23:26, Peter Maydell peter.mayd...@linaro.org wrote: On 23 February 2012 14:36, Magnus Therning mag...@therning.org wrote: Qemu seems to mostly ship with emulation of individual CPUs (e.g. ARM processors) and with emulation of boards (e.g. versatile), is it also used for emulation of SoC? Yes. Our infrastructure for doing it in a neatly encapsulated way has been a bit lacking but is getting better. Already in the tree there is emulation of OMAP1 and OMAP2 and (just landed) the Samsung Exynos4210. Excellent, I'll have to take a look at those then. It sounds like I/O of general-purpose micro controllers, like A/D converters and PWM, would have to be written, is that correct? I've looked around a bit, and found some indications of it, e.g. a branch that allows connection between SystemC and qemu. SystemC support is a completely unrelated question to whether we emulate SoCs. (We don't have any SystemC support in mainline, as it happens.) Well, true, except maybe that SystemC could be a way to write the co-processors/peripherals on the SoC. /M -- Magnus Therning OpenPGP: 0xAB4DFBA4 email: mag...@therning.org jabber: mag...@therning.org twitter: magthe http://therning.org/magnus
Re: [Qemu-devel] Qemu for simulating SoCs?
On 24 February 2012 10:20, Magnus Therning mag...@therning.org wrote: Well, true, except maybe that SystemC could be a way to write the co-processors/peripherals on the SoC. None of this is at all relevant to mainline qemu, but you might be interested in the proceedings of the 2011 QEMU Users Forum which contains several reports on using SystemC with QEMU: http://adt.cs.upb.de/quf/ Alex
Re: [Qemu-devel] Qemu for simulating SoCs?
On 24 February 2012 10:20, Magnus Therning mag...@therning.org wrote: On Thu, Feb 23, 2012 at 23:26, Peter Maydell peter.mayd...@linaro.org wrote: Yes. Our infrastructure for doing it in a neatly encapsulated way has been a bit lacking but is getting better. Already in the tree there is emulation of OMAP1 and OMAP2 and (just landed) the Samsung Exynos4210. Excellent, I'll have to take a look at those then. It sounds like I/O of general-purpose micro controllers, like A/D converters and PWM, would have to be written, is that correct? Depends entirely on what SoC you're modelling and what it has on it. A SoC is just a collection of devices which happen to be on one piece of silicon. If you're lucky we have models of those device; if you're unlucky we don't and you need to write them. (Probably you'll be unlucky; there's a lot of variation and most SoC vendors seem to use their own flavours of everything.) I've looked around a bit, and found some indications of it, e.g. a branch that allows connection between SystemC and qemu. SystemC support is a completely unrelated question to whether we emulate SoCs. (We don't have any SystemC support in mainline, as it happens.) Well, true, except maybe that SystemC could be a way to write the co-processors/peripherals on the SoC. That would be rather taking the long way around compared to just writing the peripherals as native qemu device models. NB that at the moment qemu doesn't support having more than one actual CPU; usually where a SoC has some kind of DSP or coprocessor we just don't bother modelling it. -- PMM
Re: [Qemu-devel] [PATCH v2] nic: zap obsolote romloading bits from ne2k + pcnet
On 02/08/12 16:02, Gerd Hoffmann wrote: These days one just needs to specify the romfile in PCiDeviceInfo and everything magically works. It also allows to disable pxe rom loading via romfile=emptystring like it is possible for all other nics. [ v2: rebased adapted to qom changes ] ping? cheers, Gerd
Re: [Qemu-devel] [libvirt] Add GSoC project ideas to the wiki!
On 24.02.2012 10:19, Stefan Hajnoczi wrote: This is a reminder that QEMU will apply for Google Summer of Code 2012 and we need project ideas and mentors. Libvirt and kvm.ko projects are also welcome! http://wiki.qemu.org/Google_Summer_of_Code_2012 Please add yourself to the wiki now if you want to mentor a project this summer. I will file our application next week. Thanks, Stefan Hi Stefan, Thank you for the opportunity. I was personally thinking about something libvirt-snmp related. Nowdays, it is difficult to add new elements to MIB, as some parts of code were generated by mib2c. Any change to MIB requires regeneration of such source files and thus leads to loss of all previous changes. So one thing that is coming to my mind is drop this dependency and use libsnmp directly. But I am not sure it is worth of GSoC. Michal
Re: [Qemu-devel] [PATCH] build: allow turning off debuginfo
On 02/08/12 13:54, Gerd Hoffmann wrote: This patch adds --{enable,disable}-debug-info switches to configure which allows to include/exclude the '-g' switch on the gcc ld command lines. Not building debug info reduces ressource usage (especially disk) alot and is quite useful for test builds. ping? cheers, Gerd
Re: [Qemu-devel] FLR capability hidden in VF config space
Thanks Alex. Pls see my responses below: On Thu, Feb 23, 2012 at 9:34 PM, Alex Williamson alex.william...@redhat.com wrote: On Thu, 2012-02-23 at 09:25 +0530, rukhsana ansari wrote: Hello, Was wondering whether someone could shed some light on the issue below. Without FLR exposed in the VF, VF reset via FLR cannot be initiated from the guest. Appreciate any pointers. The device state needs to be restored after an FLR. A guest is not able to do this by this by itself as much of the config space is virtualized. That means qemu needs to be involved in the FLR. It's possible we could trap FLR and call reset_assign_device(). Patches welcome. Why do want to reset the device? [RA] While trying to figure out what the reason for not exposing FLR in VF, I had missed out what you brought up about the VF config space being virtualized. The reason for looking at FLR support in VF (apart from ease of testing using setpci) is as a possible replacement of driver specific mechanism to initiate software FLR (for example via mailbox mechanism) when VF driver get a shutdown call. But given the issue with config space being virtualized, it makes sense to continue with the current approach The following code snippet (line 1457, function:assigned_device_pci_cap_init() file: hw/device-assignment.c) from the latest qemu-kvm git (qemu-kvm-devel: 1.0.50) implies that FLR capability is unset for VF that is assigned to a guest: /* device capabilities: hide FLR */ devcap = pci_get_long(pci_dev-config + pos + PCI_EXP_DEVCAP); devcap = ~PCI_EXP_DEVCAP_FLR; pci_set_long(pci_dev-config + pos + PCI_EXP_DEVCAP, devcap); However the SR-IOV spec mandates VF FLR. The SR-IOV spec mandates that the VF supports FLR. That doesn't mean it has to be exposed though to a guest. Thanks, [RA] Yes, point noted. -- -Rukhsana
Re: [Qemu-devel] [PATCH] build: allow turning off debuginfo
On 24 February 2012 10:39, Gerd Hoffmann kra...@redhat.com wrote: On 02/08/12 13:54, Gerd Hoffmann wrote: This patch adds --{enable,disable}-debug-info switches to configure which allows to include/exclude the '-g' switch on the gcc ld command lines. Not building debug info reduces ressource usage (especially disk) alot and is quite useful for test builds. ping? We've had this suggested before, haven't we? I quite like the existing just build with -g and strip it later approach... is the resource usage change really that significant? -- PMM
Re: [Qemu-devel] [PATCH 1/2] block: add the support for draining the throttled request queue
On Fri, Feb 24, 2012 at 05:25:08PM +0800, Zhi Yong Wu wrote: On Fri, Feb 24, 2012 at 4:49 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Mon, Feb 20, 2012 at 12:50:30PM +0800, zwu.ker...@gmail.com wrote: From: Zhi Yong Wu wu...@linux.vnet.ibm.com If one guest has multiple disks with enabling I/O throttling function separately, when draining activities are done, some requests maybe are in the throttled queue; So we need to restart them at first. Moreover, when only one disk need to be drained such as hotplug out, if another disk still has some requests in its throttled queue, these request should not be effected. Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com --- block.c | 29 ++--- block_int.h | 1 + 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index ae297bb..f78df78 100644 --- a/block.c +++ b/block.c @@ -853,25 +853,40 @@ void bdrv_close_all(void) } } -/* - * Wait for pending requests to complete across all BlockDriverStates - * - * This function does not flush data to disk, use bdrv_flush_all() for that - * after calling this function. - */ -void bdrv_drain_all(void) +void bdrv_drain_request(BlockDriverState *throttled_bs) { BlockDriverState *bs; + QTAILQ_FOREACH(bs, bdrv_states, list) { + if (throttled_bs throttled_bs != bs) { + continue; + } + qemu_co_queue_restart_all(bs-throttled_reqs); + } + qemu_aio_flush(); Since I/O throttling is still enabled, the restarted requests could enqueue again if they exceed the limit. We could still hit the assert. If the semantics of bdrv_drain_request() are that no requests are pending when it returns then we need a loop here. BTW bdrv_drain() would be a shorter name for this function. For this function's semantics, i have some concerns. Is it used to drain all requests of one single disk or all disks for one guest? which is more suitable? Both are useful: /** * Complete all pending requests for a block device */ void bdrv_drain(BlockDriverState *bs); /** * Complete pending requests for all block devices */ void bdrv_drain_all(void); Stefan
Re: [Qemu-devel] [PATCH] split SCSI and LSI, add myself as SCSI maintainer
Am 22.02.2012 15:59, schrieb Paolo Bonzini: This has been the de facto situation for a while now. Add a tree, too. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- MAINTAINERS |9 +++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 647c413..0b3b3d8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -420,11 +420,16 @@ F: hw/pci* F: hw/piix* SCSI +M: Paolo Bonzini pbonz...@redhat.com +S: Supported +F: hw/virtio-scsi.* +F: hw/scsi* +T: git://github.com/bonzini/qemu.git scsi-next + +LSI53C895A M: Paul Brook p...@codesourcery.com -M: Kevin Wolf kw...@redhat.com S: Odd Fixes F: hw/lsi53c895a.c -F: hw/scsi* USB M: Gerd Hoffmann kra...@redhat.com Acked-by: Kevin Wolf kw...@redhat.com
[Qemu-devel] [PATCH 1/2] Add blkmirror block driver
From: Marcelo Tosatti mtosa...@redhat.com Mirrored writes are used by live block copy. Signed-off-by: Marcelo Tosatti mtosa...@redhat.com Signed-off-by: Federico Simoncelli fsimo...@redhat.com --- Makefile.objs |2 +- block/blkmirror.c | 247 docs/blkmirror.txt | 16 3 files changed, 264 insertions(+), 1 deletions(-) create mode 100644 block/blkmirror.c create mode 100644 docs/blkmirror.txt diff --git a/Makefile.objs b/Makefile.objs index 67ee3df..6020308 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -34,7 +34,7 @@ block-nested-y += raw.o cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vv block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-cache.o block-nested-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o block-nested-y += qed-check.o -block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o +block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o blkmirror.o block-nested-y += stream.o block-nested-$(CONFIG_WIN32) += raw-win32.o block-nested-$(CONFIG_POSIX) += raw-posix.o diff --git a/block/blkmirror.c b/block/blkmirror.c new file mode 100644 index 000..39927c8 --- /dev/null +++ b/block/blkmirror.c @@ -0,0 +1,247 @@ +/* + * Block driver for mirrored writes. + * + * Copyright (C) 2011 Red Hat, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include stdarg.h +#include block_int.h + +typedef struct { +BlockDriverState *bs[2]; +} BdrvMirrorState; + +typedef struct DupAIOCB DupAIOCB; + +typedef struct SingleAIOCB { +BlockDriverAIOCB *aiocb; +int finished; +DupAIOCB *parent; +} SingleAIOCB; + +struct DupAIOCB { +BlockDriverAIOCB common; +int count; + +BlockDriverCompletionFunc *cb; +SingleAIOCB aios[2]; +int ret; +}; + +/* Valid blkmirror filenames look like + * blkmirror:path/to/image1:path/to/image2 */ +static int blkmirror_open(BlockDriverState *bs, const char *filename, int flags) +{ +BdrvMirrorState *m = bs-opaque; +int ret, escape, i, n; +char *filename2; + +/* Parse the blkmirror: prefix */ +if (strncmp(filename, blkmirror:, strlen(blkmirror:))) { +return -EINVAL; +} +filename += strlen(blkmirror:); + +/* Parse the raw image filename */ +filename2 = g_malloc(strlen(filename)+1); +escape = 0; +for (i = n = 0; i strlen(filename); i++) { +if (!escape filename[i] == ':') { +break; +} +if (!escape filename[i] == '\\') { +escape = 1; +} else { +escape = 0; +} + +if (!escape) { +filename2[n++] = filename[i]; +} +} +filename2[n] = '\0'; + +m-bs[0] = bdrv_new(); +if (m-bs[0] == NULL) { +g_free(filename2); +return -ENOMEM; +} +ret = bdrv_open(m-bs[0], filename2, flags, NULL); +g_free(filename2); +if (ret 0) { +return ret; +} +filename += i + 1; + +m-bs[1] = bdrv_new(); +if (m-bs[1] == NULL) { +bdrv_delete(m-bs[0]); +return -ENOMEM; +} +ret = bdrv_open(m-bs[1], filename, flags, NULL); +if (ret 0) { +bdrv_delete(m-bs[0]); +return ret; +} + +return 0; +} + +static void blkmirror_close(BlockDriverState *bs) +{ +BdrvMirrorState *m = bs-opaque; +int i; + +for (i = 0; i 2; i++) { +bdrv_delete(m-bs[i]); +m-bs[i] = NULL; +} +} + +static coroutine_fn int blkmirror_co_flush(BlockDriverState *bs) +{ +BdrvMirrorState *m = bs-opaque; +int ret; + +ret = bdrv_co_flush(m-bs[0]); +if (ret 0) { +return ret; +} + +return bdrv_co_flush(m-bs[1]); +} + +static int64_t blkmirror_getlength(BlockDriverState *bs) +{ +BdrvMirrorState *m = bs-opaque; + +return bdrv_getlength(m-bs[0]); +} + +static BlockDriverAIOCB *blkmirror_aio_readv(BlockDriverState *bs, + int64_t sector_num, + QEMUIOVector *qiov, + int nb_sectors, + BlockDriverCompletionFunc *cb, + void *opaque) +{ +BdrvMirrorState *m = bs-opaque; +return bdrv_aio_readv(m-bs[0], sector_num, qiov, nb_sectors, cb, opaque); +} + +static void dup_aio_cancel(BlockDriverAIOCB *blockacb) +{ +DupAIOCB *acb = container_of(blockacb, DupAIOCB, common); +int i; + +for (i = 0 ; i 2; i++) { +if (!acb-aios[i].finished) { +bdrv_aio_cancel(acb-aios[i].aiocb); +} +} +qemu_aio_release(acb); +} + +static AIOPool dup_aio_pool = { +.aiocb_size = sizeof(DupAIOCB), +.cancel = dup_aio_cancel, +}; + +static void blkmirror_aio_cb(void *opaque, int ret) +{ +
[Qemu-devel] [PATCH] hw/arm11mpcore: Fix broken realview_mpcore/arm11mpcore_priv properties
Fix confusion in the Property arrays for the arm11mpcore_priv (per-CPU devices for the ARM11MPcore CPU) and realview_mpcore (realview-eb board specific device encapsulating CPU and some extra interrupt controllers) -- the num-irq property was defined on the wrong device and the mpcore_rirq_properties were defined as offsets in the wrong structure. The effect was that the realview-eb-mpcore machine would abort on startup trying to allocate an insane amount of memory. (This bug was introduced in the QOM conversion in commit 999e12bb.) Signed-off-by: Peter Maydell peter.mayd...@linaro.org --- The trouble with doing all this as macro magic is that you end up repeating yourself and nothing errors out saying you fool, when you typed the name of the object struct for the nth time you got it wrong... hw/arm11mpcore.c | 20 ++-- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/arm11mpcore.c b/hw/arm11mpcore.c index 102348b..c67b70f 100644 --- a/hw/arm11mpcore.c +++ b/hw/arm11mpcore.c @@ -202,16 +202,7 @@ static int realview_mpcore_init(SysBusDevice *dev) } static Property mpcore_rirq_properties[] = { -DEFINE_PROP_UINT32(num-cpu, mpcore_priv_state, num_cpu, 1), -/* The ARM11 MPCORE TRM says the on-chip controller may have - * anything from 0 to 224 external interrupt IRQ lines (with another - * 32 internal). We default to 32+32, which is the number provided by - * the ARM11 MPCore test chip in the Realview Versatile Express - * coretile. Other boards may differ and should set this property - * appropriately. Some Linux kernels may not boot if the hardware - * has more IRQ lines than the kernel expects. - */ -DEFINE_PROP_UINT32(num-irq, mpcore_priv_state, num_irq, 64), +DEFINE_PROP_UINT32(num-cpu, mpcore_rirq_state, num_cpu, 1), DEFINE_PROP_END_OF_LIST(), }; @@ -233,6 +224,15 @@ static TypeInfo mpcore_rirq_info = { static Property mpcore_priv_properties[] = { DEFINE_PROP_UINT32(num-cpu, mpcore_priv_state, num_cpu, 1), +/* The ARM11 MPCORE TRM says the on-chip controller may have + * anything from 0 to 224 external interrupt IRQ lines (with another + * 32 internal). We default to 32+32, which is the number provided by + * the ARM11 MPCore test chip in the Realview Versatile Express + * coretile. Other boards may differ and should set this property + * appropriately. Some Linux kernels may not boot if the hardware + * has more IRQ lines than the kernel expects. + */ +DEFINE_PROP_UINT32(num-irq, mpcore_priv_state, num_irq, 64), DEFINE_PROP_END_OF_LIST(), }; -- 1.7.1
[Qemu-devel] [PATCH 2/2] Add the blockdev-reopen and blockdev-migrate commands
Signed-off-by: Federico Simoncelli fsimo...@redhat.com --- block/blkmirror.c |2 +- blockdev.c| 109 +++-- hmp-commands.hx | 36 + hmp.c | 30 ++ hmp.h |2 + qapi-schema.json | 63 ++ 6 files changed, 229 insertions(+), 13 deletions(-) diff --git a/block/blkmirror.c b/block/blkmirror.c index 39927c8..49e3381 100644 --- a/block/blkmirror.c +++ b/block/blkmirror.c @@ -81,7 +81,7 @@ static int blkmirror_open(BlockDriverState *bs, const char *filename, int flags) bdrv_delete(m-bs[0]); return -ENOMEM; } -ret = bdrv_open(m-bs[1], filename, flags, NULL); +ret = bdrv_open(m-bs[1], filename, flags | BDRV_O_NO_BACKING, NULL); if (ret 0) { bdrv_delete(m-bs[0]); return ret; diff --git a/blockdev.c b/blockdev.c index 2c132a3..1df2542 100644 --- a/blockdev.c +++ b/blockdev.c @@ -646,9 +646,8 @@ void do_commit(Monitor *mon, const QDict *qdict) } } -void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, -bool has_format, const char *format, -Error **errp) +static void change_blockdev_image(const char *device, const char *new_image_file, + const char *format, bool create, Error **errp) { BlockDriverState *bs; BlockDriver *drv, *old_drv, *proto_drv; @@ -671,7 +670,7 @@ void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, old_drv = bs-drv; flags = bs-open_flags; -if (!has_format) { +if (!format) { format = qcow2; } @@ -681,24 +680,26 @@ void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, return; } -proto_drv = bdrv_find_protocol(snapshot_file); +proto_drv = bdrv_find_protocol(new_image_file); if (!proto_drv) { error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); return; } -ret = bdrv_img_create(snapshot_file, format, bs-filename, - bs-drv-format_name, NULL, -1, flags); -if (ret) { -error_set(errp, QERR_UNDEFINED_ERROR); -return; +if (create) { +ret = bdrv_img_create(new_image_file, format, bs-filename, + bs-drv-format_name, NULL, -1, flags); +if (ret) { +error_set(errp, QERR_UNDEFINED_ERROR); +return; +} } bdrv_drain_all(); bdrv_flush(bs); bdrv_close(bs); -ret = bdrv_open(bs, snapshot_file, flags, drv); +ret = bdrv_open(bs, new_image_file, flags, drv); /* * If reopening the image file we just created fails, fall back * and try to re-open the original image. If that fails too, we @@ -709,11 +710,95 @@ void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, if (ret != 0) { error_set(errp, QERR_OPEN_FILE_FAILED, old_filename); } else { -error_set(errp, QERR_OPEN_FILE_FAILED, snapshot_file); +error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file); } } } +void qmp_blockdev_reopen(const char *device, const char *new_image_file, + bool has_format, const char *format, Error **errp) +{ +change_blockdev_image(device, new_image_file, + has_format ? format : NULL, false, errp); +} + +void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, +bool has_format, const char *format, +Error **errp) +{ +change_blockdev_image(device, snapshot_file, + has_format ? format : NULL, true, errp); +} + +void qmp_blockdev_migrate(const char *device, BlockMigrateOp mode, + const char *destination, bool has_new_image_file, + const char *new_image_file, Error **errp) +{ +BlockDriverState *bs; +BlockDriver *drv; +int i, j, escape; +char filename[2048]; + +bs = bdrv_find(device); +if (!bs) { +error_set(errp, QERR_DEVICE_NOT_FOUND, device); +return; +} +if (bdrv_in_use(bs)) { +error_set(errp, QERR_DEVICE_IN_USE, device); +return; +} + +if (mode == BLOCK_MIGRATE_OP_MIRROR) { +drv = bdrv_find_format(blkmirror); +if (!drv) { +error_set(errp, QERR_INVALID_BLOCK_FORMAT, blkmirror); +return; +} + +if (!has_new_image_file) { +new_image_file = bs-filename; +} + +pstrcpy(filename, sizeof(filename), blkmirror:); +i = strlen(blkmirror:); + +escape = 0; +for (j = 0; j strlen(new_image_file); j++) { + loop: +if (!(i sizeof(filename) - 2)) { +error_set(errp, QERR_INVALID_PARAMETER_VALUE, +
Re: [Qemu-devel] [PATCH] block: drop aio_multiwrite in BlockDriver
Am 21.02.2012 16:43, schrieb Paolo Bonzini: These were never used. Signed-off-by: Paolo Bonzini pbonz...@redhat.com Thanks, applied to the block branch. Kevin
[Qemu-devel] [PATCH v2 1/3] vga: simplify screendump
The displaychangelistener isn't needed at all, we can simply save the image when vga_hw_update is done instead of hooking into the update process. --- hw/vga.c | 36 +--- 1 files changed, 1 insertions(+), 35 deletions(-) diff --git a/hw/vga.c b/hw/vga.c index c1029db..f8f30f8 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -163,8 +163,6 @@ static uint16_t expand2[256]; static uint8_t expand4to8[16]; static void vga_screen_dump(void *opaque, const char *filename); -static const char *screen_dump_filename; -static DisplayChangeListener *screen_dump_dcl; static void vga_update_memory_access(VGACommonState *s) { @@ -2364,22 +2362,6 @@ void vga_init_vbe(VGACommonState *s, MemoryRegion *system_memory) // /* vga screen dump */ -static void vga_save_dpy_update(DisplayState *ds, -int x, int y, int w, int h) -{ -if (screen_dump_filename) { -ppm_save(screen_dump_filename, ds-surface); -} -} - -static void vga_save_dpy_resize(DisplayState *s) -{ -} - -static void vga_save_dpy_refresh(DisplayState *s) -{ -} - int ppm_save(const char *filename, struct DisplaySurface *ds) { FILE *f; @@ -2423,29 +2405,13 @@ int ppm_save(const char *filename, struct DisplaySurface *ds) return 0; } -static DisplayChangeListener* vga_screen_dump_init(DisplayState *ds) -{ -DisplayChangeListener *dcl; - -dcl = g_malloc0(sizeof(DisplayChangeListener)); -dcl-dpy_update = vga_save_dpy_update; -dcl-dpy_resize = vga_save_dpy_resize; -dcl-dpy_refresh = vga_save_dpy_refresh; -register_displaychangelistener(ds, dcl); -return dcl; -} - /* save the vga display in a PPM image even if no display is available */ static void vga_screen_dump(void *opaque, const char *filename) { VGACommonState *s = opaque; -if (!screen_dump_dcl) -screen_dump_dcl = vga_screen_dump_init(s-ds); - -screen_dump_filename = filename; vga_invalidate_display(s); vga_hw_update(); -screen_dump_filename = NULL; +ppm_save(filename, s-ds-surface); } -- 1.7.1
[Qemu-devel] [PATCH v2 2/3] Remove screendump dummy functions.
The code in console.c verifies whenever a screen_dump function pointer is present before calling it, so there is no need to supply an dummy function. Remove them. Also report an error to notify the user that he didn't got a screenshot. --- console.c |2 ++ hw/jazz_led.c |7 +-- hw/pxa2xx_lcd.c |7 +-- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/console.c b/console.c index 135394f..153424f 100644 --- a/console.c +++ b/console.c @@ -184,6 +184,8 @@ void vga_hw_screen_dump(const char *filename) console_select(0); if (consoles[0] consoles[0]-hw_screen_dump) { consoles[0]-hw_screen_dump(consoles[0]-hw, filename); +} else { +error_report(screen dump not implemented); } if (previous_active_console) { diff --git a/hw/jazz_led.c b/hw/jazz_led.c index 5d8040b..6486523 100644 --- a/hw/jazz_led.c +++ b/hw/jazz_led.c @@ -205,11 +205,6 @@ static void jazz_led_invalidate_display(void *opaque) s-state |= REDRAW_SEGMENTS | REDRAW_BACKGROUND; } -static void jazz_led_screen_dump(void *opaque, const char *filename) -{ -printf(jazz_led_screen_dump() not implemented\n); -} - static void jazz_led_text_update(void *opaque, console_ch_t *chardata) { LedState *s = opaque; @@ -255,7 +250,7 @@ static int jazz_led_init(SysBusDevice *dev) s-ds = graphic_console_init(jazz_led_update_display, jazz_led_invalidate_display, - jazz_led_screen_dump, + NULL, jazz_led_text_update, s); return 0; diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c index 9495226..fcbdfb3 100644 --- a/hw/pxa2xx_lcd.c +++ b/hw/pxa2xx_lcd.c @@ -899,11 +899,6 @@ static void pxa2xx_invalidate_display(void *opaque) s-invalidated = 1; } -static void pxa2xx_screen_dump(void *opaque, const char *filename) -{ -/* TODO */ -} - static void pxa2xx_lcdc_orientation(void *opaque, int angle) { PXA2xxLCDState *s = (PXA2xxLCDState *) opaque; @@ -1009,7 +1004,7 @@ PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem, s-ds = graphic_console_init(pxa2xx_update_display, pxa2xx_invalidate_display, - pxa2xx_screen_dump, NULL, s); + NULL, NULL, s); switch (ds_get_bits_per_pixel(s-ds)) { case 0: -- 1.7.1
[Qemu-devel] [PATCH v2 0/3] screendump fixups
Hi, Next round, this time covering all screen dump implementations. cheers, Gerd Gerd Hoffmann (3): vga: simplify screendump Remove screendump dummy functions. optimize screendump for the common non-switch case console.c | 12 +--- console.h |2 +- hw/blizzard.c |8 ++-- hw/g364fb.c |2 +- hw/jazz_led.c |7 +-- hw/omap_lcdc.c |7 +-- hw/pxa2xx_lcd.c |7 +-- hw/qxl.c|4 ++-- hw/tcx.c|8 hw/vga.c| 46 +++--- hw/vmware_vga.c |4 ++-- 11 files changed, 39 insertions(+), 68 deletions(-)
[Qemu-devel] [PATCH v2 3/3] optimize screendump for the common non-switch case
switch console only if needed, also pass down whenever the console was switched or not because a displaysurface redraw is only needed in case the console was switched. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- console.c | 10 +++--- console.h |2 +- hw/blizzard.c |8 ++-- hw/g364fb.c |2 +- hw/omap_lcdc.c |7 +-- hw/qxl.c|4 ++-- hw/tcx.c|8 hw/vga.c| 10 ++ hw/vmware_vga.c |4 ++-- 9 files changed, 34 insertions(+), 21 deletions(-) diff --git a/console.c b/console.c index 153424f..da3dd07 100644 --- a/console.c +++ b/console.c @@ -176,19 +176,23 @@ void vga_hw_invalidate(void) void vga_hw_screen_dump(const char *filename) { TextConsole *previous_active_console; +bool cswitch; previous_active_console = active_console; +cswitch = previous_active_console previous_active_console-index != 0; /* There is currently no way of specifying which screen we want to dump, so always dump the first one. */ -console_select(0); +if (cswitch) { +console_select(0); +} if (consoles[0] consoles[0]-hw_screen_dump) { -consoles[0]-hw_screen_dump(consoles[0]-hw, filename); +consoles[0]-hw_screen_dump(consoles[0]-hw, filename, cswitch); } else { error_report(screen dump not implemented); } -if (previous_active_console) { +if (cswitch) { console_select(previous_active_console-index); } } diff --git a/console.h b/console.h index 6ba0d5d..1fc8ea3 100644 --- a/console.h +++ b/console.h @@ -340,7 +340,7 @@ static inline void console_write_ch(console_ch_t *dest, uint32_t ch) typedef void (*vga_hw_update_ptr)(void *); typedef void (*vga_hw_invalidate_ptr)(void *); -typedef void (*vga_hw_screen_dump_ptr)(void *, const char *); +typedef void (*vga_hw_screen_dump_ptr)(void *, const char *, bool cswitch); typedef void (*vga_hw_text_update_ptr)(void *, console_ch_t *); DisplayState *graphic_console_init(vga_hw_update_ptr update, diff --git a/hw/blizzard.c b/hw/blizzard.c index b2c1b22..c7d844d 100644 --- a/hw/blizzard.c +++ b/hw/blizzard.c @@ -932,10 +932,14 @@ static void blizzard_update_display(void *opaque) s-my[1] = 0; } -static void blizzard_screen_dump(void *opaque, const char *filename) { +static void blizzard_screen_dump(void *opaque, const char *filename, + bool cswitch) +{ BlizzardState *s = (BlizzardState *) opaque; -blizzard_update_display(opaque); +if (cswitch) { +blizzard_update_display(opaque); +} if (s ds_get_data(s-state)) ppm_save(filename, s-state-surface); } diff --git a/hw/g364fb.c b/hw/g364fb.c index 9c63bdd..3a0b68f 100644 --- a/hw/g364fb.c +++ b/hw/g364fb.c @@ -289,7 +289,7 @@ static void g364fb_reset(G364State *s) g364fb_invalidate_display(s); } -static void g364fb_screen_dump(void *opaque, const char *filename) +static void g364fb_screen_dump(void *opaque, const char *filename, bool cswitch) { G364State *s = opaque; int y, x; diff --git a/hw/omap_lcdc.c b/hw/omap_lcdc.c index f265306..f172093 100644 --- a/hw/omap_lcdc.c +++ b/hw/omap_lcdc.c @@ -264,9 +264,12 @@ static int ppm_save(const char *filename, uint8_t *data, return 0; } -static void omap_screen_dump(void *opaque, const char *filename) { +static void omap_screen_dump(void *opaque, const char *filename, bool cswitch) +{ struct omap_lcd_panel_s *omap_lcd = opaque; -omap_update_display(opaque); +if (cswitch) { +omap_update_display(opaque); +} if (omap_lcd ds_get_data(omap_lcd-state)) ppm_save(filename, ds_get_data(omap_lcd-state), omap_lcd-width, omap_lcd-height, diff --git a/hw/qxl.c b/hw/qxl.c index e38bb29..f4c68ab 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -1438,7 +1438,7 @@ static void qxl_hw_invalidate(void *opaque) vga-invalidate(vga); } -static void qxl_hw_screen_dump(void *opaque, const char *filename) +static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch) { PCIQXLDevice *qxl = opaque; VGACommonState *vga = qxl-vga; @@ -1450,7 +1450,7 @@ static void qxl_hw_screen_dump(void *opaque, const char *filename) ppm_save(filename, qxl-ssd.ds-surface); break; case QXL_MODE_VGA: -vga-screen_dump(vga, filename); +vga-screen_dump(vga, filename, cswitch); break; default: break; diff --git a/hw/tcx.c b/hw/tcx.c index 2b66d86..ac7dcb4 100644 --- a/hw/tcx.c +++ b/hw/tcx.c @@ -56,8 +56,8 @@ typedef struct TCXState { uint8_t dac_index, dac_state; } TCXState; -static void tcx_screen_dump(void *opaque, const char *filename); -static void tcx24_screen_dump(void *opaque, const char *filename); +static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch); +static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch);
Re: [Qemu-devel] [PATCH v5 8/9] qxl: introduce QXLCookie
On 02/22/12 22:09, Alon Levy wrote: Will be used in the next patch. Fails checkpatch.pl. cheers, Gerd
Re: [Qemu-devel] [PATCH 2/2] Add the blockdev-reopen and blockdev-migrate commands
Am 24.02.2012 12:37, schrieb Federico Simoncelli: Signed-off-by: Federico Simoncelli fsimo...@redhat.com --- block/blkmirror.c |2 +- blockdev.c| 109 +++-- hmp-commands.hx | 36 + hmp.c | 30 ++ hmp.h |2 + qapi-schema.json | 63 ++ 6 files changed, 229 insertions(+), 13 deletions(-) diff --git a/block/blkmirror.c b/block/blkmirror.c index 39927c8..49e3381 100644 --- a/block/blkmirror.c +++ b/block/blkmirror.c @@ -81,7 +81,7 @@ static int blkmirror_open(BlockDriverState *bs, const char *filename, int flags) bdrv_delete(m-bs[0]); return -ENOMEM; } -ret = bdrv_open(m-bs[1], filename, flags, NULL); +ret = bdrv_open(m-bs[1], filename, flags | BDRV_O_NO_BACKING, NULL); if (ret 0) { bdrv_delete(m-bs[0]); return ret; Was this hunk meant to be in patch 1? diff --git a/blockdev.c b/blockdev.c index 2c132a3..1df2542 100644 --- a/blockdev.c +++ b/blockdev.c @@ -646,9 +646,8 @@ void do_commit(Monitor *mon, const QDict *qdict) } } -void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, -bool has_format, const char *format, -Error **errp) +static void change_blockdev_image(const char *device, const char *new_image_file, + const char *format, bool create, Error **errp) { BlockDriverState *bs; BlockDriver *drv, *old_drv, *proto_drv; @@ -671,7 +670,7 @@ void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, old_drv = bs-drv; flags = bs-open_flags; -if (!has_format) { +if (!format) { format = qcow2; } @@ -681,24 +680,26 @@ void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, return; } -proto_drv = bdrv_find_protocol(snapshot_file); +proto_drv = bdrv_find_protocol(new_image_file); if (!proto_drv) { error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); return; } -ret = bdrv_img_create(snapshot_file, format, bs-filename, - bs-drv-format_name, NULL, -1, flags); -if (ret) { -error_set(errp, QERR_UNDEFINED_ERROR); -return; +if (create) { +ret = bdrv_img_create(new_image_file, format, bs-filename, + bs-drv-format_name, NULL, -1, flags); +if (ret) { +error_set(errp, QERR_UNDEFINED_ERROR); +return; +} } bdrv_drain_all(); bdrv_flush(bs); bdrv_close(bs); -ret = bdrv_open(bs, snapshot_file, flags, drv); +ret = bdrv_open(bs, new_image_file, flags, drv); /* * If reopening the image file we just created fails, fall back * and try to re-open the original image. If that fails too, we @@ -709,11 +710,95 @@ void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, if (ret != 0) { error_set(errp, QERR_OPEN_FILE_FAILED, old_filename); } else { -error_set(errp, QERR_OPEN_FILE_FAILED, snapshot_file); +error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file); } } } +void qmp_blockdev_reopen(const char *device, const char *new_image_file, + bool has_format, const char *format, Error **errp) +{ +change_blockdev_image(device, new_image_file, + has_format ? format : NULL, false, errp); +} + +void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, +bool has_format, const char *format, +Error **errp) +{ +change_blockdev_image(device, snapshot_file, + has_format ? format : NULL, true, errp); +} + +void qmp_blockdev_migrate(const char *device, BlockMigrateOp mode, + const char *destination, bool has_new_image_file, + const char *new_image_file, Error **errp) +{ +BlockDriverState *bs; +BlockDriver *drv; +int i, j, escape; +char filename[2048]; + +bs = bdrv_find(device); +if (!bs) { +error_set(errp, QERR_DEVICE_NOT_FOUND, device); +return; +} +if (bdrv_in_use(bs)) { +error_set(errp, QERR_DEVICE_IN_USE, device); +return; +} + +if (mode == BLOCK_MIGRATE_OP_MIRROR) { Move into a separate function? +drv = bdrv_find_format(blkmirror); +if (!drv) { +error_set(errp, QERR_INVALID_BLOCK_FORMAT, blkmirror); +return; +} + +if (!has_new_image_file) { +new_image_file = bs-filename; +} + +
Re: [Qemu-devel] [libvirt] Add GSoC project ideas to the wiki!
On Fri, Feb 24, 2012 at 10:38 AM, Michal Privoznik mpriv...@redhat.com wrote: On 24.02.2012 10:19, Stefan Hajnoczi wrote: Thank you for the opportunity. I was personally thinking about something libvirt-snmp related. Nowdays, it is difficult to add new elements to MIB, as some parts of code were generated by mib2c. Any change to MIB requires regeneration of such source files and thus leads to loss of all previous changes. So one thing that is coming to my mind is drop this dependency and use libsnmp directly. But I am not sure it is worth of GSoC. If this project is self-contained and can be completed in 12 weeks by a person without prior libvirt and SNMP experience, but fluent C programming skills, then it sounds suitable. Is there any creativity required or problems to solve that aren't grunt work? For example, if you just need to run mib2c and then manually diff to produce the final C version, then this sounds like a lot of manual work but little gain for the student. Stefan
Re: [Qemu-devel] [PATCH 2/2] Add the blockdev-reopen and blockdev-migrate commands
- Original Message - From: Kevin Wolf kw...@redhat.com To: Federico Simoncelli fsimo...@redhat.com Cc: qemu-devel@nongnu.org, Marcelo Tosatti mtosa...@redhat.com, lcapitul...@redhat.com, Paolo Bonzini pbonz...@redhat.com, Markus Armbruster arm...@redhat.com Sent: Friday, February 24, 2012 1:03:08 PM Subject: Re: [PATCH 2/2] Add the blockdev-reopen and blockdev-migrate commands Am 24.02.2012 12:37, schrieb Federico Simoncelli: Signed-off-by: Federico Simoncelli fsimo...@redhat.com --- block/blkmirror.c |2 +- blockdev.c| 109 +++-- hmp-commands.hx | 36 + hmp.c | 30 ++ hmp.h |2 + qapi-schema.json | 63 ++ 6 files changed, 229 insertions(+), 13 deletions(-) diff --git a/block/blkmirror.c b/block/blkmirror.c index 39927c8..49e3381 100644 --- a/block/blkmirror.c +++ b/block/blkmirror.c @@ -81,7 +81,7 @@ static int blkmirror_open(BlockDriverState *bs, const char *filename, int flags) bdrv_delete(m-bs[0]); return -ENOMEM; } -ret = bdrv_open(m-bs[1], filename, flags, NULL); +ret = bdrv_open(m-bs[1], filename, flags | BDRV_O_NO_BACKING, NULL); if (ret 0) { bdrv_delete(m-bs[0]); return ret; Was this hunk meant to be in patch 1? Not necessarily, I thought a lot about it. I didn't want to modify Marcelo's patch too much. This flag is actually mandatory only to make blockdev-migrate work with a destination that doesn't have a backing file yet, so I thought it was more appropriate to squash it here. -- Federico
Re: [Qemu-devel] [PATCH 1/2] block: add the support for draining the throttled request queue
On 02/24/2012 09:49 AM, Stefan Hajnoczi wrote: +void bdrv_drain_request(BlockDriverState *throttled_bs) { BlockDriverState *bs; +QTAILQ_FOREACH(bs, bdrv_states, list) { +if (throttled_bs throttled_bs != bs) { +continue; +} +qemu_co_queue_restart_all(bs-throttled_reqs); +} + qemu_aio_flush(); Since I/O throttling is still enabled, the restarted requests could enqueue again if they exceed the limit. We could still hit the assert. Yes, and qemu_aio_flush() rightly doesn't know that there are pending requests, because these are not there until the timer fires. Perhaps the bug is simply that the assert is bogus. If there are throttled requests, we need to invoke qemu_aio_flush() again. The problem with this is that timers don't run inside qemu_aio_wait() so we have to restart them all and we're effectively busy waiting. Not a huge problem since qemu_aio_flush() is rare, but not too nice either. Paolo
Re: [Qemu-devel] [PATCH 1/7] Introduce a new bus ICC to connect APIC
On 02/17/2012 06:02 PM, Igor Mammedov wrote: On 02/16/2012 01:42 PM, Anthony Liguori wrote: On 02/16/2012 05:25 AM, Jan Kiszka wrote: On 2012-02-16 00:16, Igor Mammedov wrote: Introduce a new structure CPUS as the controller of ICC (INTERRUPT CONTROLLER COMMUNICATIONS), and new bus ICC to hold APIC,instead of sysbus. So we can support APIC hot-plug feature. This is repost of original patch for qemu-kvm rebased on current qemu: http://lists.nongnu.org/archive/html/qemu-devel/2011-11/msg01478.html All credits to Liu Ping Fan for writing it. V2 changes: - cpusockets_init: cpu_sockets is not yet initialized, use cpus that we got as input param instead for qbus_create, this makes cpus apics visible in info qtree monitor command - fix format error spotted by Jan and missed by checkpatch - cpu_has_apic_feature: return bool instead of int This patch surely no longer applies. And the ICC requires QOM conversion. Also, post-QOM, I don't think having an ICC bus makes a whole lot of sense. The LAPIC can be made a child of the CPU device with a bidirectional link. I would simply create a fixed set of CPU links hung off of /devices somewhere and use that as the hotplug mechanism. This matches well the way we model this to the guest (we expose a fixed number of pluggable sockets). I've just QOM-ified it, but in light of what you just said it may be ignored. ICC bus was used on pre Pentium 4 smp systems. And whole thing with introducing it was to provide hot-plugable bus for cpus, since hot-plug on sysbus is disabled and people argued that sysbus shouldn't be hot-plugable. However it depends on what we choose to model, we can use pre P4 ICC bus for inter-apic/ioapic communications or use P4 model allowing hot-plug on sysbus and use it for inter-apic/ioapic communications if needed. So I'd rather drop ICC patch and try your approach with CPU links, I see no point in introducing new bus providing we have an alternative model and existing bus for the task. I've looked at device_add command and qdev_device_add it uses for doing actual work and in current state it requires (based on Andreas' qom_cpu branch): For approach where apic and cpu hot-plugged to sysbus. 1. created object must be descendant of TYPE_DEVICE. So QOM TYPE_CPU should be inherited from TYPE_DEVICE at least or TYPE_SYS_BUS_DEVICE. 2. hot-plug on the bus should be allowed. if we ditch icc bus then we should allow hot-plug on sysbus. Can we do this? (i.e. it seems that for P4 and later cpus sysbus should be hot-plugable). 3. should DeviceClass.init be used for cpu initialization or should .instance_init do all the job and make DeviceClass.init nop? Another approach that tries to re-use device_add interface: 1. allow run-time type detection in qdev_device_add and execute separate branch for TYPE_CPU. This way we could easily use links on sysbus 2. device_del will require the same hacking as device_add 3. apic now is sysbus device, question is what will be lost if it is attached to link and won't be sysbus_device_type anymore? 4. will reset called on sysbus reach apic/cpu if it is on the link? Any opinions on direction I should look more closely?
Re: [Qemu-devel] [PATCH 1/2] block: add the support for draining the throttled request queue
On Fri, Feb 24, 2012 at 7:18 PM, Stefan Hajnoczi stefa...@linux.vnet.ibm.com wrote: On Fri, Feb 24, 2012 at 05:25:08PM +0800, Zhi Yong Wu wrote: On Fri, Feb 24, 2012 at 4:49 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Mon, Feb 20, 2012 at 12:50:30PM +0800, zwu.ker...@gmail.com wrote: From: Zhi Yong Wu wu...@linux.vnet.ibm.com If one guest has multiple disks with enabling I/O throttling function separately, when draining activities are done, some requests maybe are in the throttled queue; So we need to restart them at first. Moreover, when only one disk need to be drained such as hotplug out, if another disk still has some requests in its throttled queue, these request should not be effected. Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com --- block.c | 29 ++--- block_int.h | 1 + 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index ae297bb..f78df78 100644 --- a/block.c +++ b/block.c @@ -853,25 +853,40 @@ void bdrv_close_all(void) } } -/* - * Wait for pending requests to complete across all BlockDriverStates - * - * This function does not flush data to disk, use bdrv_flush_all() for that - * after calling this function. - */ -void bdrv_drain_all(void) +void bdrv_drain_request(BlockDriverState *throttled_bs) { BlockDriverState *bs; + QTAILQ_FOREACH(bs, bdrv_states, list) { + if (throttled_bs throttled_bs != bs) { + continue; + } + qemu_co_queue_restart_all(bs-throttled_reqs); + } + qemu_aio_flush(); Since I/O throttling is still enabled, the restarted requests could enqueue again if they exceed the limit. We could still hit the assert. If the semantics of bdrv_drain_request() are that no requests are pending when it returns then we need a loop here. BTW bdrv_drain() would be a shorter name for this function. For this function's semantics, i have some concerns. Is it used to drain all requests of one single disk or all disks for one guest? which is more suitable? Both are useful: /** * Complete all pending requests for a block device */ void bdrv_drain(BlockDriverState *bs); /** * Complete pending requests for all block devices */ void bdrv_drain_all(void); Great, thanks. Stefan -- Regards, Zhi Yong Wu
Re: [Qemu-devel] [PATCH 2/2] Add the blockdev-reopen and blockdev-migrate commands
On 02/24/2012 01:03 PM, Kevin Wolf wrote: + loop: +if (!(i sizeof(filename) - 2)) { +error_set(errp, QERR_INVALID_PARAMETER_VALUE, + new-image-file, shorter filename); +return; +} + +if (new_image_file[j] == ':' || new_image_file[j] == '\\') { Markus suggested that using comma for the separator is better even though it requires escaping. It would allow to parse the option string with QemuOpts. Isn't that a bit overengineering for an internal interface? +if (!escape) { +filename[i++] = '\\', escape = 1; +goto loop; +} else { +escape = 0; +} +} + +filename[i++] = new_image_file[j]; +} Looks like a string helper for qemu-option.c (it contains the parser, so keeping the escaping nearby would make sense). + +if (i + strlen(destination) + 2 sizeof(filename)) { +error_set(errp, QERR_INVALID_PARAMETER_VALUE, + destination, shorter filename); +return; +} + +filename[i++] = ':'; +pstrcpy(filename + i, sizeof(filename) - i - 2, destination); + +change_blockdev_image(device, filename, blkmirror, false, errp); +} else if (mode == BLOCK_MIGRATE_OP_STREAM) { +error_set(errp, QERR_NOT_SUPPORTED); Why even define it then? Because it's the default for the HMP. Until we have live merging, mirror mode cannot be consider anything more than a hack. ## +# @blockdev-reopen +# +# Assigns a new image file to a device. +# +# @device: the name of the device for which we are chainging the image file. +# +# @new-image-file: the target of the new image. If the file doesn't exists the +# command will fail. +# +# @format: #optional the format of the new image, default is 'qcow2'. +# +# Returns: nothing on success +# If @device is not a valid block device, DeviceNotFound +# If @new-image-file can't be opened, OpenFileFailed +# If @format is invalid, InvalidBlockFormat +# +# Since 1.1 +## + +{ 'command': 'blockdev-reopen', + 'data': { 'device': 'str', 'new-image-file': 'str', '*format': 'str' } } Same consideration on the name. Also I think we should immediately mark the command as deprecated (I think there is precedence for it, though I can't remember which command it was). This is not an interface we'll want to keep long term. What about blockdev-snapshot-sync/snapshot_blkdev? Paolo
Re: [Qemu-devel] [PATCH 1/7] Introduce a new bus ICC to connect APIC
Am 24.02.2012 14:05, schrieb Igor Mammedov: On 02/17/2012 06:02 PM, Igor Mammedov wrote: So I'd rather drop ICC patch and try your approach with CPU links, I see no point in introducing new bus providing we have an alternative model and existing bus for the task. I've looked at device_add command and qdev_device_add it uses for doing actual work and in current state it requires (based on Andreas' qom_cpu branch): For approach where apic and cpu hot-plugged to sysbus. 1. created object must be descendant of TYPE_DEVICE. So QOM TYPE_CPU should be inherited from TYPE_DEVICE at least or TYPE_SYS_BUS_DEVICE. 2. hot-plug on the bus should be allowed. if we ditch icc bus then we should allow hot-plug on sysbus. Can we do this? (i.e. it seems that for P4 and later cpus sysbus should be hot-plugable). 3. should DeviceClass.init be used for cpu initialization or should .instance_init do all the job and make DeviceClass.init nop? SysBus is supposed to go away in Anthony's upcoming 4th QOM series, so I'd rather not base a new series on that. The issue with TYPE_DEVICE is that we don't want to leak that into the user emulators (would break the build), and any infrastructure only available to qdev should gradually be made accessible to all objects (Paolo has done some work in that direction wrt properties). So the main remaining difference between Object and Device is the GPIO IRQ support. Anthony wanted to introduce Pin objects to replace qemu_irq. As for init, the idea was to have initialization code in an initfn, the resulting state is then supposed to be overridable by the user (e.g., set family, model, stepping differently on the CPU) and then do the construction work in a realize function that corresponds more closely to DeviceClass::init. This too, still needs to be generalized. Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 1/7] Introduce a new bus ICC to connect APIC
On 02/24/2012 02:30 PM, Andreas Färber wrote: SysBus is supposed to go away in Anthony's upcoming 4th QOM series, so I'd rather not base a new series on that. Not sure about that. I haven't understood well the scope of the series, but I think it only converted buses to QOM, it didn't kill them. Perhaps SysBus was special, in which case it would become automatically hotpluggable: just create a new QOM object. The issue with TYPE_DEVICE is that we don't want to leak that into the user emulators (would break the build), and any infrastructure only available to qdev should gradually be made accessible to all objects (Paolo has done some work in that direction wrt properties). I haven't, but it would be next on the list of things to do. So the main remaining difference between Object and Device is the GPIO IRQ support. Anthony wanted to introduce Pin objects to replace qemu_irq. Aiming at replacing is a bad idea unless you can do it fast and painlessly. Adding gpio_in and gpio_out property types would be more useful and would let you expose qemu_irq as QOM. You can then change the existing qdev.c functions to operate on those new property types. Paolo
Re: [Qemu-devel] [PATCH 1/7] Introduce a new bus ICC to connect APIC
On 02/24/2012 07:40 AM, Paolo Bonzini wrote: On 02/24/2012 02:30 PM, Andreas Färber wrote: SysBus is supposed to go away in Anthony's upcoming 4th QOM series, so I'd rather not base a new series on that. Not sure about that. I haven't understood well the scope of the series, but I think it only converted buses to QOM, it didn't kill them. Perhaps SysBus was special, in which case it would become automatically hotpluggable: just create a new QOM object. The issue with TYPE_DEVICE is that we don't want to leak that into the user emulators (would break the build), and any infrastructure only available to qdev should gradually be made accessible to all objects (Paolo has done some work in that direction wrt properties). I haven't, but it would be next on the list of things to do. So the main remaining difference between Object and Device is the GPIO IRQ support. Anthony wanted to introduce Pin objects to replace qemu_irq. Aiming at replacing is a bad idea unless you can do it fast and painlessly. Adding gpio_in and gpio_out property types would be more useful and would let you expose qemu_irq as QOM. I agree with you in principle, but in practice, there is not obvious way to serialize gpio_in/gpio_out via Visitors. Finding some way to do it as an integer is clearly wrong IMHO. I think a simple Pin object with the following interfaces: /** * Connect a pin to a qemu_irq such that whenever the pin is * raised, qemu_irq_raise() is called too on irq. */ void pin_connect_qemu_irq(Pin *obj, qemu_irq irq); /** * Returns a qemu_irq such that whenever qemu_irq_raise() is * called, pin_set_level(obj, true) is called. */ qemu_irq pin_get_qemu_irq(Pin *obj); Let's you incrementally refactor objects to use Pins while maintaining the existing qemu_irq infrastructure. Regards, Anthony Liguori You can then change the existing qdev.c functions to operate on those new property types. Paolo
Re: [Qemu-devel] [PATCH 1/7] Introduce a new bus ICC to connect APIC
On 02/24/2012 02:47 PM, Anthony Liguori wrote: I agree with you in principle, but in practice, there is not obvious way to serialize gpio_in/gpio_out via Visitors. Finding some way to do it as an integer is clearly wrong IMHO. %s/gpio_in[%d] % (object_get_canonical_path(...), opaque-n) is what I was thinking about. I think a simple Pin object with the following interfaces: /** * Connect a pin to a qemu_irq such that whenever the pin is * raised, qemu_irq_raise() is called too on irq. */ void pin_connect_qemu_irq(Pin *obj, qemu_irq irq); /** * Returns a qemu_irq such that whenever qemu_irq_raise() is * called, pin_set_level(obj, true) is called. */ qemu_irq pin_get_qemu_irq(Pin *obj); Let's you incrementally refactor objects to use Pins while maintaining the existing qemu_irq infrastructure. Sure, a simple bridge is a fine alternative. What I'm not sure about is making Pins stateful, because that means you have to serialize them. Paolo
Re: [Qemu-devel] [PATCH v4 14/18] virtio-scsi: process control queue requests
On 02/24/2012 08:54 AM, Hu Tao wrote: diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index 380073a..1f3b851 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -239,7 +239,7 @@ static VirtIOSCSIReq *virtio_scsi_pop_req(VirtIOSCSI *s, VirtQueue *vq) static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) { -SCSIDevice *d = virtio_scsi_device_find(s, req-req.cmd-lun); +SCSIDevice *d = virtio_scsi_device_find(s, req-req.tmf-lun); SCSIRequest *r, *next; DeviceState *qdev; int target; @@ -253,11 +253,11 @@ static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) if (!d) { goto fail; } -if (d-lun != virtio_scsi_get_lun(req-req.cmd-lun)) { +if (d-lun != virtio_scsi_get_lun(req-req.tmf-lun)) { goto incorrect_lun; } QTAILQ_FOREACH_SAFE(r, d-requests, next, next) { -if (r-tag == req-req.cmd-tag) { +if (r-tag == req-req.tmf-tag) { break; } } @@ -277,7 +277,7 @@ static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) if (!d) { goto fail; } -if (d-lun != virtio_scsi_get_lun(req-req.cmd-lun)) { +if (d-lun != virtio_scsi_get_lun(req-req.tmf-lun)) { goto incorrect_lun; } s-resetting++; @@ -291,7 +291,7 @@ static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) if (!d) { goto fail; } -if (d-lun != virtio_scsi_get_lun(req-req.cmd-lun)) { +if (d-lun != virtio_scsi_get_lun(req-req.tmf-lun)) { goto incorrect_lun; } QTAILQ_FOREACH_SAFE(r, d-requests, next, next) { @@ -310,7 +310,7 @@ static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) break; case VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET: -target = req-req.cmd-lun[1]; +target = req-req.tmf-lun[1]; s-resetting++; QTAILQ_FOREACH(qdev, s-bus.qbus.children, sibling) { d = DO_UPCAST(SCSIDevice, qdev, qdev); This is now fixed on github. Paolo
[Qemu-devel] [PULL 0/3] Trivial patches for 11 to 24 February 2012
The following changes since commit 235fe3bfd46b1104575b540d0bc3fdf584030b99: qom: add test tools (2012-02-22 12:18:26 -0600) are available in the git repository at: git://github.com/stefanha/qemu.git trivial-patches for you to fetch changes up to f293d8b1f26953ccaef794785cea0619d4f8c268: slirp/misc: fix gcc __warn_memset_zero_len warnings (2012-02-24 13:24:42 +) Alon Levy (1): slirp/misc: fix gcc __warn_memset_zero_len warnings Peter Maydell (1): vl.c: Increase width of machine name column in -M ? output Stefan Weil (1): tcg: Remove unneeded include statements slirp/misc.c | 21 +++-- tcg/tcg.c| 12 vl.c |4 ++-- 3 files changed, 9 insertions(+), 28 deletions(-) -- 1.7.9
[Qemu-devel] [PATCH 1/3] tcg: Remove unneeded include statements
From: Stefan Weil s...@weilnetz.de The standard include files are already included in qemu-common.h. malloc.h and alloca.h were needed for alloca() which was removed from TCG code some years ago when switching from dyngen to TCG (see commit 49516bc0d622112caac9df628caf19010fda8b67). Signed-off-by: Stefan Weil s...@weilnetz.de Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com --- tcg/tcg.c | 12 1 files changed, 0 insertions(+), 12 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index d43fa4a..351a0a3 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -33,18 +33,6 @@ #define NDEBUG #endif -#include stdarg.h -#include stdlib.h -#include stdio.h -#include string.h -#include inttypes.h -#ifdef _WIN32 -#include malloc.h -#endif -#ifdef _AIX -#include alloca.h -#endif - #include qemu-common.h #include cache-utils.h #include host-utils.h -- 1.7.9
[Qemu-devel] [PATCH 2/3] vl.c: Increase width of machine name column in -M ? output
From: Peter Maydell peter.mayd...@linaro.org Increase the width of the column used for the machine name in the -M ? output from 10 to 20 spaces. This fixes the formatting so it looks nice for architectures where a few of the machines have overly long names. (Our current longest machine name is petalogix-s3adsp1800 with realview-eb-mpcore not far behind.) Signed-off-by: Peter Maydell peter.mayd...@linaro.org Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com --- vl.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vl.c b/vl.c index 7a8cc08..f211c71 100644 --- a/vl.c +++ b/vl.c @@ -1999,9 +1999,9 @@ static QEMUMachine *machine_parse(const char *name) printf(Supported machines are:\n); for (m = first_machine; m != NULL; m = m-next) { if (m-alias) { -printf(%-10s %s (alias of %s)\n, m-alias, m-desc, m-name); +printf(%-20s %s (alias of %s)\n, m-alias, m-desc, m-name); } -printf(%-10s %s%s\n, m-name, m-desc, +printf(%-20s %s%s\n, m-name, m-desc, m-is_default ? (default) : ); } exit(!name || *name != '?'); -- 1.7.9
[Qemu-devel] [PATCH 3/3] slirp/misc: fix gcc __warn_memset_zero_len warnings
From: Alon Levy al...@redhat.com By removing memset altogether (Patch from Stefan Hajnoczi, tested compile only by me). Signed-off-by: Alon Levy al...@redhat.com Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com --- slirp/misc.c | 21 +++-- 1 files changed, 7 insertions(+), 14 deletions(-) diff --git a/slirp/misc.c b/slirp/misc.c index 3432fbf..0308a62 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -333,7 +333,6 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon) struct socket *so; const char *state; char buf[20]; -int n; monitor_printf(mon, Protocol[State]FD Source Address Port Dest. Address Port RecvQ SendQ\n); @@ -357,10 +356,8 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon) dst_addr = so-so_faddr; dst_port = so-so_fport; } -n = snprintf(buf, sizeof(buf), TCP[%s], state); -memset(buf[n], ' ', 19 - n); -buf[19] = 0; -monitor_printf(mon, %s %3d %15s %5d , buf, so-s, +snprintf(buf, sizeof(buf), TCP[%s], state); +monitor_printf(mon, %-19s %3d %15s %5d , buf, so-s, src.sin_addr.s_addr ? inet_ntoa(src.sin_addr) : *, ntohs(src.sin_port)); monitor_printf(mon, %15s %5d %5d %5d\n, @@ -370,22 +367,20 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon) for (so = slirp-udb.so_next; so != slirp-udb; so = so-so_next) { if (so-so_state SS_HOSTFWD) { -n = snprintf(buf, sizeof(buf), UDP[HOST_FORWARD]); +snprintf(buf, sizeof(buf), UDP[HOST_FORWARD]); src_len = sizeof(src); getsockname(so-s, (struct sockaddr *)src, src_len); dst_addr = so-so_laddr; dst_port = so-so_lport; } else { -n = snprintf(buf, sizeof(buf), UDP[%d sec], +snprintf(buf, sizeof(buf), UDP[%d sec], (so-so_expire - curtime) / 1000); src.sin_addr = so-so_laddr; src.sin_port = so-so_lport; dst_addr = so-so_faddr; dst_port = so-so_fport; } -memset(buf[n], ' ', 19 - n); -buf[19] = 0; -monitor_printf(mon, %s %3d %15s %5d , buf, so-s, +monitor_printf(mon, %-19s %3d %15s %5d , buf, so-s, src.sin_addr.s_addr ? inet_ntoa(src.sin_addr) : *, ntohs(src.sin_port)); monitor_printf(mon, %15s %5d %5d %5d\n, @@ -394,13 +389,11 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon) } for (so = slirp-icmp.so_next; so != slirp-icmp; so = so-so_next) { -n = snprintf(buf, sizeof(buf), ICMP[%d sec], +snprintf(buf, sizeof(buf), ICMP[%d sec], (so-so_expire - curtime) / 1000); src.sin_addr = so-so_laddr; dst_addr = so-so_faddr; -memset(buf[n], ' ', 19 - n); -buf[19] = 0; -monitor_printf(mon, %s %3d %15s -, buf, so-s, +monitor_printf(mon, %-19s %3d %15s -, buf, so-s, src.sin_addr.s_addr ? inet_ntoa(src.sin_addr) : *); monitor_printf(mon, %15s -%5d %5d\n, inet_ntoa(dst_addr), so-so_rcv.sb_cc, so-so_snd.sb_cc); -- 1.7.9
Re: [Qemu-devel] [RFC] sdl: initialize all graphic consoles
On Thu, 23 Feb 2012, Anthony Liguori wrote: diff --git a/console.c b/console.c index 135394f..2c413a7 100644 --- a/console.c +++ b/console.c @@ -1376,6 +1376,9 @@ DisplayState *get_displaystate(void) if (!display_state) { dumb_display_init (); } +if (active_console active_console-ds) { +return active_console-ds; +} return display_state; } You should be wary of all the callers of this function because they probably assume that there is just one DisplayState and may not cope well with a multiple DisplayState scenario. It might be better to rename this function get_active_displaystate or get_current_displaystate. Even better would be to replace it entirely with a for_each_display_state type of iterator, see for example pci_for_each_device or irq_domain_for_each_irq in Linux. diff --git a/vl.c b/vl.c index 7a8cc08..98e0091 100644 --- a/vl.c +++ b/vl.c @@ -3451,8 +3451,14 @@ int main(int argc, char **argv, char **envp) #endif #if defined(CONFIG_SDL) case DT_SDL: -sdl_display_init(ds, full_screen, no_frame); +{ +DisplayState *ds2 = ds; +while (ds2) { +sdl_display_init(ds2, full_screen, no_frame); +ds2 = ds2-next; The fact that this works at all really surprises me. You're registering double input event handlers and doing a number of things that have a global state. sdl_display_init() isn't meant to be called twice. I really think more substantial refactoring is needed such that we're not maintaining the UI state as globals and can independently instantiate a backend for a given DisplayState. I had some patches that I posted a bit ago that started down this direction. Like Anthony wrote, you probably need a more substantial refactoring to make this work, but the basic idea that you can call graphic_console_init twice to instantiate two DisplayState instances is correct. Then you should be able to call sdl_display_init on all of them independently. If sdl_display_init (or any other display_init function) modifies a single global state, that needs to be fixed.
[Qemu-devel] [PATCH 0/5]: Improve machine type functions
I was reading some related code yesterday and couldn't resist improving this. Not sure if this is aligned with any possible QOM work in this area, but I'm posting this anyway... Makefile.target |3 +- hw/alpha_dp264.c |2 +- hw/an5206.c |2 +- hw/axis_dev88.c |2 +- hw/boards.c | 86 + hw/boards.h |9 +++- hw/collie.c |2 +- hw/dummy_m68k.c |2 +- hw/exynos4_boards.c |4 +- hw/gumstix.c |4 +- hw/highbank.c |2 +- hw/integratorcp.c |2 +- hw/leon3.c|2 +- hw/lm32_boards.c |4 +- hw/mainstone.c|2 +- hw/mcf5208.c |2 +- hw/milkymist.c|2 +- hw/mips_fulong2e.c|2 +- hw/mips_jazz.c|4 +- hw/mips_malta.c |2 +- hw/mips_mipssim.c |2 +- hw/mips_r4k.c |2 +- hw/musicpal.c |2 +- hw/nseries.c |4 +- hw/omap_sx1.c |4 +- hw/palm.c |2 +- hw/pc_piix.c | 20 +- hw/pc_sysfw.c |2 +- hw/petalogix_ml605_mmu.c |2 +- hw/petalogix_s3adsp1800_mmu.c |2 +- hw/ppc405_boards.c|4 +- hw/ppc440_bamboo.c|2 +- hw/ppc_newworld.c |2 +- hw/ppc_oldworld.c |2 +- hw/ppc_prep.c |2 +- hw/ppce500_mpc8544ds.c|2 +- hw/r2d.c |2 +- hw/realview.c |8 ++-- hw/s390-virtio.c |2 +- hw/shix.c |2 +- hw/spapr.c|2 +- hw/spitz.c|8 ++-- hw/stellaris.c|4 +- hw/sun4m.c| 24 ++-- hw/sun4u.c|6 +- hw/tosa.c |2 +- hw/versatilepb.c |4 +- hw/vexpress.c |4 +- hw/virtex_ml507.c |2 +- hw/xen_machine_pv.c |2 +- hw/xtensa_lx60.c |4 +- hw/xtensa_sim.c |2 +- hw/z2.c |2 +- vl.c | 65 +-- 54 files changed, 184 insertions(+), 157 deletions(-)
[Qemu-devel] [PATCH 1/5] boards: qemu_register_machine(): return void
It never fails. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- hw/boards.h |2 +- vl.c|3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/boards.h b/hw/boards.h index 667177d..7a9899f 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -31,7 +31,7 @@ typedef struct QEMUMachine { struct QEMUMachine *next; } QEMUMachine; -int qemu_register_machine(QEMUMachine *m); +void qemu_register_machine(QEMUMachine *m); QEMUMachine *find_default_machine(void); extern QEMUMachine *current_machine; diff --git a/vl.c b/vl.c index 7a8cc08..45fc3b5 100644 --- a/vl.c +++ b/vl.c @@ -1163,7 +1163,7 @@ void pcmcia_info(Monitor *mon) static QEMUMachine *first_machine = NULL; QEMUMachine *current_machine = NULL; -int qemu_register_machine(QEMUMachine *m) +void qemu_register_machine(QEMUMachine *m) { QEMUMachine **pm; pm = first_machine; @@ -1171,7 +1171,6 @@ int qemu_register_machine(QEMUMachine *m) pm = (*pm)-next; m-next = NULL; *pm = m; -return 0; } static QEMUMachine *find_machine(const char *name) -- 1.7.9.111.gf3fb0.dirty
Re: [Qemu-devel] [PATCH 1/5] boards: qemu_register_machine(): return void
Am 24.02.2012 15:13, schrieb Luiz Capitulino: It never fails. ...and is never checked. Low-impact cleanup, thanks. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com Reviewed-by: Andreas Färber afaer...@suse.de Andreas --- hw/boards.h |2 +- vl.c|3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/boards.h b/hw/boards.h index 667177d..7a9899f 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -31,7 +31,7 @@ typedef struct QEMUMachine { struct QEMUMachine *next; } QEMUMachine; -int qemu_register_machine(QEMUMachine *m); +void qemu_register_machine(QEMUMachine *m); QEMUMachine *find_default_machine(void); extern QEMUMachine *current_machine; diff --git a/vl.c b/vl.c index 7a8cc08..45fc3b5 100644 --- a/vl.c +++ b/vl.c @@ -1163,7 +1163,7 @@ void pcmcia_info(Monitor *mon) static QEMUMachine *first_machine = NULL; QEMUMachine *current_machine = NULL; -int qemu_register_machine(QEMUMachine *m) +void qemu_register_machine(QEMUMachine *m) { QEMUMachine **pm; pm = first_machine; @@ -1171,7 +1171,6 @@ int qemu_register_machine(QEMUMachine *m) pm = (*pm)-next; m-next = NULL; *pm = m; -return 0; } static QEMUMachine *find_machine(const char *name) -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ
Am 24.02.2012 15:13, schrieb Luiz Capitulino: Signed-off-by: Luiz Capitulino lcapitul...@redhat.com Unless this fixes a bug, I'd rather not refactor this as in my head this is already just object_class_foreach() / object_class_by_name(), similar to CPUs on my qom-cpu branch. Andreas --- hw/boards.h |3 ++- vl.c| 16 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/hw/boards.h b/hw/boards.h index 342a774..1eb8314 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -4,6 +4,7 @@ #define HW_BOARDS_H #include qdev.h +#include qemu-queue.h typedef void QEMUMachineInitFunc(ram_addr_t ram_size, const char *boot_device, @@ -28,7 +29,7 @@ typedef struct QEMUMachine { int is_default; const char *default_machine_opts; GlobalProperty *compat_props; -struct QEMUMachine *next; +QTAILQ_ENTRY(QEMUMachine) next; } QEMUMachine; void machine_register(QEMUMachine *m); diff --git a/vl.c b/vl.c index 9f9927c..4935106 100644 --- a/vl.c +++ b/vl.c @@ -1160,24 +1160,20 @@ void pcmcia_info(Monitor *mon) /***/ /* machine registration */ -static QEMUMachine *first_machine = NULL; +static QTAILQ_HEAD(QEMUMachineHead, QEMUMachine) machine_types = +QTAILQ_HEAD_INITIALIZER(machine_types); QEMUMachine *current_machine = NULL; void machine_register(QEMUMachine *m) { -QEMUMachine **pm; -pm = first_machine; -while (*pm != NULL) -pm = (*pm)-next; -m-next = NULL; -*pm = m; +QTAILQ_INSERT_TAIL(machine_types, m, next); } static QEMUMachine *machine_find(const char *name) { QEMUMachine *m; -for(m = first_machine; m != NULL; m = m-next) { +QTAILQ_FOREACH(m, machine_types, next) { if (!strcmp(m-name, name)) return m; if (m-alias !strcmp(m-alias, name)) @@ -1190,7 +1186,7 @@ QEMUMachine *machine_find_default(void) { QEMUMachine *m; -for(m = first_machine; m != NULL; m = m-next) { +QTAILQ_FOREACH(m, machine_types, next) { if (m-is_default) { return m; } @@ -1203,7 +1199,7 @@ void machine_print_all(void) QEMUMachine *m; printf(Supported machines are:\n); -for (m = first_machine; m != NULL; m = m-next) { +QTAILQ_FOREACH(m, machine_types, next) { if (m-alias) { printf(%-10s %s (alias of %s)\n, m-alias, m-desc, m-name); } -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
[Qemu-devel] [PATCH 2/5] boards: rename machine type functions
Perform the following renames: o qemu_register_machine() - machine_register() o find_machine() - machine_find() o find_default_machine() - machine_find_default() Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- hw/alpha_dp264.c |2 +- hw/an5206.c |2 +- hw/axis_dev88.c |2 +- hw/boards.h |4 ++-- hw/collie.c |2 +- hw/dummy_m68k.c |2 +- hw/exynos4_boards.c |4 ++-- hw/gumstix.c |4 ++-- hw/highbank.c |2 +- hw/integratorcp.c |2 +- hw/leon3.c|2 +- hw/lm32_boards.c |4 ++-- hw/mainstone.c|2 +- hw/mcf5208.c |2 +- hw/milkymist.c|2 +- hw/mips_fulong2e.c|2 +- hw/mips_jazz.c|4 ++-- hw/mips_malta.c |2 +- hw/mips_mipssim.c |2 +- hw/mips_r4k.c |2 +- hw/musicpal.c |2 +- hw/nseries.c |4 ++-- hw/omap_sx1.c |4 ++-- hw/palm.c |2 +- hw/pc_piix.c | 20 ++-- hw/pc_sysfw.c |2 +- hw/petalogix_ml605_mmu.c |2 +- hw/petalogix_s3adsp1800_mmu.c |2 +- hw/ppc405_boards.c|4 ++-- hw/ppc440_bamboo.c|2 +- hw/ppc_newworld.c |2 +- hw/ppc_oldworld.c |2 +- hw/ppc_prep.c |2 +- hw/ppce500_mpc8544ds.c|2 +- hw/r2d.c |2 +- hw/realview.c |8 hw/s390-virtio.c |2 +- hw/shix.c |2 +- hw/spapr.c|2 +- hw/spitz.c|8 hw/stellaris.c|4 ++-- hw/sun4m.c| 24 hw/sun4u.c|6 +++--- hw/tosa.c |2 +- hw/versatilepb.c |4 ++-- hw/vexpress.c |4 ++-- hw/virtex_ml507.c |2 +- hw/xen_machine_pv.c |2 +- hw/xtensa_lx60.c |4 ++-- hw/xtensa_sim.c |2 +- hw/z2.c |2 +- vl.c | 10 +- 52 files changed, 96 insertions(+), 96 deletions(-) diff --git a/hw/alpha_dp264.c b/hw/alpha_dp264.c index ea0fd95..21f7729 100644 --- a/hw/alpha_dp264.c +++ b/hw/alpha_dp264.c @@ -174,7 +174,7 @@ static QEMUMachine clipper_machine = { static void clipper_machine_init(void) { -qemu_register_machine(clipper_machine); +machine_register(clipper_machine); } machine_init(clipper_machine_init); diff --git a/hw/an5206.c b/hw/an5206.c index d57306d..5361576 100644 --- a/hw/an5206.c +++ b/hw/an5206.c @@ -90,7 +90,7 @@ static QEMUMachine an5206_machine = { static void an5206_machine_init(void) { -qemu_register_machine(an5206_machine); +machine_register(an5206_machine); } machine_init(an5206_machine_init); diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c index c9301fd..549aaa5 100644 --- a/hw/axis_dev88.c +++ b/hw/axis_dev88.c @@ -356,7 +356,7 @@ static QEMUMachine axisdev88_machine = { static void axisdev88_machine_init(void) { -qemu_register_machine(axisdev88_machine); +machine_register(axisdev88_machine); } machine_init(axisdev88_machine_init); diff --git a/hw/boards.h b/hw/boards.h index 7a9899f..098cbb7 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -31,8 +31,8 @@ typedef struct QEMUMachine { struct QEMUMachine *next; } QEMUMachine; -void qemu_register_machine(QEMUMachine *m); -QEMUMachine *find_default_machine(void); +void machine_register(QEMUMachine *m); +QEMUMachine *machine_find_default(void); extern QEMUMachine *current_machine; diff --git a/hw/collie.c b/hw/collie.c index 42f4310..cdcf722 100644 --- a/hw/collie.c +++ b/hw/collie.c @@ -65,7 +65,7 @@ static QEMUMachine collie_machine = { static void collie_machine_init(void) { -qemu_register_machine(collie_machine); +machine_register(collie_machine); } machine_init(collie_machine_init) diff --git a/hw/dummy_m68k.c b/hw/dummy_m68k.c index e3c5740..30562bb 100644 --- a/hw/dummy_m68k.c +++ b/hw/dummy_m68k.c @@ -77,7 +77,7 @@ static QEMUMachine dummy_m68k_machine = { static void dummy_m68k_machine_init(void) { -qemu_register_machine(dummy_m68k_machine); +machine_register(dummy_m68k_machine); } machine_init(dummy_m68k_machine_init); diff --git a/hw/exynos4_boards.c b/hw/exynos4_boards.c index 553a02b..5b1e717 100644 --- a/hw/exynos4_boards.c +++ b/hw/exynos4_boards.c @@ -170,8 +170,8 @@ static QEMUMachine exynos4_machines[EXYNOS4_NUM_OF_BOARDS] = { static void exynos4_machine_init(void) { -qemu_register_machine(exynos4_machines[EXYNOS4_BOARD_NURI]); -
Re: [Qemu-devel] [PATCH 3/5] boards: introduce machine_print_all()
Am 24.02.2012 15:13, schrieb Luiz Capitulino: Print all registered machine types. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com I'm okay with the code movement, but is there a reason not to make it static? Needs a rebase due to 10 - 20 bump by Peter. Andreas --- hw/boards.h |1 + vl.c| 25 - 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/hw/boards.h b/hw/boards.h index 098cbb7..342a774 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -33,6 +33,7 @@ typedef struct QEMUMachine { void machine_register(QEMUMachine *m); QEMUMachine *machine_find_default(void); +void machine_print_all(void); extern QEMUMachine *current_machine; diff --git a/vl.c b/vl.c index 81cc5b1..9f9927c 100644 --- a/vl.c +++ b/vl.c @@ -1198,6 +1198,20 @@ QEMUMachine *machine_find_default(void) return NULL; } +void machine_print_all(void) +{ +QEMUMachine *m; + +printf(Supported machines are:\n); +for (m = first_machine; m != NULL; m = m-next) { +if (m-alias) { +printf(%-10s %s (alias of %s)\n, m-alias, m-desc, m-name); +} +printf(%-10s %s%s\n, m-name, m-desc, + m-is_default ? (default) : ); +} +} + /***/ /* main execution loop */ @@ -1987,7 +2001,7 @@ static int debugcon_parse(const char *devname) static QEMUMachine *machine_parse(const char *name) { -QEMUMachine *m, *machine = NULL; +QEMUMachine *machine = NULL; if (name) { machine = machine_find(name); @@ -1995,14 +2009,7 @@ static QEMUMachine *machine_parse(const char *name) if (machine) { return machine; } -printf(Supported machines are:\n); -for (m = first_machine; m != NULL; m = m-next) { -if (m-alias) { -printf(%-10s %s (alias of %s)\n, m-alias, m-desc, m-name); -} -printf(%-10s %s%s\n, m-name, m-desc, - m-is_default ? (default) : ); -} +machine_print_all(); exit(!name || *name != '?'); } -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
[Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ
Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- hw/boards.h |3 ++- vl.c| 16 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/hw/boards.h b/hw/boards.h index 342a774..1eb8314 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -4,6 +4,7 @@ #define HW_BOARDS_H #include qdev.h +#include qemu-queue.h typedef void QEMUMachineInitFunc(ram_addr_t ram_size, const char *boot_device, @@ -28,7 +29,7 @@ typedef struct QEMUMachine { int is_default; const char *default_machine_opts; GlobalProperty *compat_props; -struct QEMUMachine *next; +QTAILQ_ENTRY(QEMUMachine) next; } QEMUMachine; void machine_register(QEMUMachine *m); diff --git a/vl.c b/vl.c index 9f9927c..4935106 100644 --- a/vl.c +++ b/vl.c @@ -1160,24 +1160,20 @@ void pcmcia_info(Monitor *mon) /***/ /* machine registration */ -static QEMUMachine *first_machine = NULL; +static QTAILQ_HEAD(QEMUMachineHead, QEMUMachine) machine_types = +QTAILQ_HEAD_INITIALIZER(machine_types); QEMUMachine *current_machine = NULL; void machine_register(QEMUMachine *m) { -QEMUMachine **pm; -pm = first_machine; -while (*pm != NULL) -pm = (*pm)-next; -m-next = NULL; -*pm = m; +QTAILQ_INSERT_TAIL(machine_types, m, next); } static QEMUMachine *machine_find(const char *name) { QEMUMachine *m; -for(m = first_machine; m != NULL; m = m-next) { +QTAILQ_FOREACH(m, machine_types, next) { if (!strcmp(m-name, name)) return m; if (m-alias !strcmp(m-alias, name)) @@ -1190,7 +1186,7 @@ QEMUMachine *machine_find_default(void) { QEMUMachine *m; -for(m = first_machine; m != NULL; m = m-next) { +QTAILQ_FOREACH(m, machine_types, next) { if (m-is_default) { return m; } @@ -1203,7 +1199,7 @@ void machine_print_all(void) QEMUMachine *m; printf(Supported machines are:\n); -for (m = first_machine; m != NULL; m = m-next) { +QTAILQ_FOREACH(m, machine_types, next) { if (m-alias) { printf(%-10s %s (alias of %s)\n, m-alias, m-desc, m-name); } -- 1.7.9.111.gf3fb0.dirty
[Qemu-devel] [PATCH 3/5] boards: introduce machine_print_all()
Print all registered machine types. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- hw/boards.h |1 + vl.c| 25 - 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/hw/boards.h b/hw/boards.h index 098cbb7..342a774 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -33,6 +33,7 @@ typedef struct QEMUMachine { void machine_register(QEMUMachine *m); QEMUMachine *machine_find_default(void); +void machine_print_all(void); extern QEMUMachine *current_machine; diff --git a/vl.c b/vl.c index 81cc5b1..9f9927c 100644 --- a/vl.c +++ b/vl.c @@ -1198,6 +1198,20 @@ QEMUMachine *machine_find_default(void) return NULL; } +void machine_print_all(void) +{ +QEMUMachine *m; + +printf(Supported machines are:\n); +for (m = first_machine; m != NULL; m = m-next) { +if (m-alias) { +printf(%-10s %s (alias of %s)\n, m-alias, m-desc, m-name); +} +printf(%-10s %s%s\n, m-name, m-desc, + m-is_default ? (default) : ); +} +} + /***/ /* main execution loop */ @@ -1987,7 +2001,7 @@ static int debugcon_parse(const char *devname) static QEMUMachine *machine_parse(const char *name) { -QEMUMachine *m, *machine = NULL; +QEMUMachine *machine = NULL; if (name) { machine = machine_find(name); @@ -1995,14 +2009,7 @@ static QEMUMachine *machine_parse(const char *name) if (machine) { return machine; } -printf(Supported machines are:\n); -for (m = first_machine; m != NULL; m = m-next) { -if (m-alias) { -printf(%-10s %s (alias of %s)\n, m-alias, m-desc, m-name); -} -printf(%-10s %s%s\n, m-name, m-desc, - m-is_default ? (default) : ); -} +machine_print_all(); exit(!name || *name != '?'); } -- 1.7.9.111.gf3fb0.dirty
[Qemu-devel] [PATCH 5/5] boards: move all machine type functions to boards.c
The license text is the same as used in vl.c. Also note that it's necessary to make machine_parse() public. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- Makefile.target |3 +- hw/boards.c | 86 +++ hw/boards.h |1 + vl.c| 65 - 4 files changed, 89 insertions(+), 66 deletions(-) create mode 100644 hw/boards.c diff --git a/Makefile.target b/Makefile.target index d5eb70d..dc76eba 100644 --- a/Makefile.target +++ b/Makefile.target @@ -195,7 +195,8 @@ endif #CONFIG_BSD_USER # System emulator target ifdef CONFIG_SOFTMMU -obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o +obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o \ + boards.o # virtio has to be here due to weird dependency between PCI and virtio-net. # need to fix this properly obj-$(CONFIG_NO_PCI) += pci-stub.o diff --git a/hw/boards.c b/hw/boards.c new file mode 100644 index 000..73d6b93 --- /dev/null +++ b/hw/boards.c @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the Software), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include hw/boards.h +#include qemu-queue.h + +static QTAILQ_HEAD(QEMUMachineHead, QEMUMachine) machine_types = +QTAILQ_HEAD_INITIALIZER(machine_types); +QEMUMachine *current_machine = NULL; + +void machine_register(QEMUMachine *m) +{ +QTAILQ_INSERT_TAIL(machine_types, m, next); +} + +static QEMUMachine *machine_find(const char *name) +{ +QEMUMachine *m; + +QTAILQ_FOREACH(m, machine_types, next) { +if (!strcmp(m-name, name)) +return m; +if (m-alias !strcmp(m-alias, name)) +return m; +} +return NULL; +} + +QEMUMachine *machine_find_default(void) +{ +QEMUMachine *m; + +QTAILQ_FOREACH(m, machine_types, next) { +if (m-is_default) { +return m; +} +} +return NULL; +} + +void machine_print_all(void) +{ +QEMUMachine *m; + +printf(Supported machines are:\n); +QTAILQ_FOREACH(m, machine_types, next) { +if (m-alias) { +printf(%-10s %s (alias of %s)\n, m-alias, m-desc, m-name); +} +printf(%-10s %s%s\n, m-name, m-desc, + m-is_default ? (default) : ); +} +} + +QEMUMachine *machine_parse(const char *name) +{ +QEMUMachine *machine = NULL; + +if (name) { +machine = machine_find(name); +} +if (machine) { +return machine; +} +machine_print_all(); +exit(!name || *name != '?'); +} diff --git a/hw/boards.h b/hw/boards.h index 1eb8314..d5e110f 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -35,6 +35,7 @@ typedef struct QEMUMachine { void machine_register(QEMUMachine *m); QEMUMachine *machine_find_default(void); void machine_print_all(void); +QEMUMachine *machine_parse(const char *name); extern QEMUMachine *current_machine; diff --git a/vl.c b/vl.c index 4935106..4ae05fd 100644 --- a/vl.c +++ b/vl.c @@ -1158,57 +1158,6 @@ void pcmcia_info(Monitor *mon) } /***/ -/* machine registration */ - -static QTAILQ_HEAD(QEMUMachineHead, QEMUMachine) machine_types = -QTAILQ_HEAD_INITIALIZER(machine_types); -QEMUMachine *current_machine = NULL; - -void machine_register(QEMUMachine *m) -{ -QTAILQ_INSERT_TAIL(machine_types, m, next); -} - -static QEMUMachine *machine_find(const char *name) -{ -QEMUMachine *m; - -QTAILQ_FOREACH(m, machine_types, next) { -if (!strcmp(m-name, name)) -return m; -if (m-alias !strcmp(m-alias, name)) -return m; -} -return NULL; -} - -QEMUMachine *machine_find_default(void) -{ -QEMUMachine *m; - -QTAILQ_FOREACH(m, machine_types, next) { -if (m-is_default) { -return m; -} -} -return NULL; -} - -void
Re: [Qemu-devel] [PATCH 1/7] Introduce a new bus ICC to connect APIC
On 02/24/2012 07:50 AM, Paolo Bonzini wrote: On 02/24/2012 02:47 PM, Anthony Liguori wrote: I agree with you in principle, but in practice, there is not obvious way to serialize gpio_in/gpio_out via Visitors. Finding some way to do it as an integer is clearly wrong IMHO. %s/gpio_in[%d] % (object_get_canonical_path(...), opaque-n) is what I was thinking about. This creates another namespace that's independent of the QOM graph. This is something we should try to avoid. I think a simple Pin object with the following interfaces: /** * Connect a pin to a qemu_irq such that whenever the pin is * raised, qemu_irq_raise() is called too on irq. */ void pin_connect_qemu_irq(Pin *obj, qemu_irq irq); /** * Returns a qemu_irq such that whenever qemu_irq_raise() is * called, pin_set_level(obj, true) is called. */ qemu_irq pin_get_qemu_irq(Pin *obj); Let's you incrementally refactor objects to use Pins while maintaining the existing qemu_irq infrastructure. Sure, a simple bridge is a fine alternative. What I'm not sure about is making Pins stateful, because that means you have to serialize them. Being stateful is a feature but the concept would work just as well if you didn't store the pin state. Then it just looks like: struct Pin { Object parent; /* private */ NotifierLister level_change_notifiers; }; The reason to introduce another type (instead of attempting to convert qemu_irq) is that the life cycle of qemu_irq is very un-QOM. I don't think we can do it without incrementally refactoring the users of qemu_irq and a new type makes it easier to do that incrementally. Regards, Anthony Liguori Paolo
Re: [Qemu-devel] [PATCH 0/5]: Improve machine type functions
On 02/24/2012 08:13 AM, Luiz Capitulino wrote: I was reading some related code yesterday and couldn't resist improving this. Not sure if this is aligned with any possible QOM work in this area, but I'm posting this anyway... I'm not sure how easy this is, but the way to do this with QOM would be: 1) Introduce a Machine abstract type. It would have the normal properties for the various machine parameters we have today (that are standard for all machines). 2) Convert all the registered users of QEMUMachine to subtypes of Machine. Note that this would tremendously simplify PC since each version could subclass the previous and we wouldn't need to duplicate globals. Use a realize() method to trigger what we think of as the machine-init() function today (but it would take no parameters). 3) Change machine listing to a object_type_foreach() call that passed TYPE_MACHINE for 'implements'. 4) Change machine initialization to creating an object of type (3), setting the properties appropriately, and then calling the realize() method of the object. That's not to say this series isn't a good cleanup. I haven't actually reviewed it yet. I just wanted to illustrate the next QOM steps. Regards, Anthony Liguori Makefile.target |3 +- hw/alpha_dp264.c |2 +- hw/an5206.c |2 +- hw/axis_dev88.c |2 +- hw/boards.c | 86 + hw/boards.h |9 +++- hw/collie.c |2 +- hw/dummy_m68k.c |2 +- hw/exynos4_boards.c |4 +- hw/gumstix.c |4 +- hw/highbank.c |2 +- hw/integratorcp.c |2 +- hw/leon3.c|2 +- hw/lm32_boards.c |4 +- hw/mainstone.c|2 +- hw/mcf5208.c |2 +- hw/milkymist.c|2 +- hw/mips_fulong2e.c|2 +- hw/mips_jazz.c|4 +- hw/mips_malta.c |2 +- hw/mips_mipssim.c |2 +- hw/mips_r4k.c |2 +- hw/musicpal.c |2 +- hw/nseries.c |4 +- hw/omap_sx1.c |4 +- hw/palm.c |2 +- hw/pc_piix.c | 20 +- hw/pc_sysfw.c |2 +- hw/petalogix_ml605_mmu.c |2 +- hw/petalogix_s3adsp1800_mmu.c |2 +- hw/ppc405_boards.c|4 +- hw/ppc440_bamboo.c|2 +- hw/ppc_newworld.c |2 +- hw/ppc_oldworld.c |2 +- hw/ppc_prep.c |2 +- hw/ppce500_mpc8544ds.c|2 +- hw/r2d.c |2 +- hw/realview.c |8 ++-- hw/s390-virtio.c |2 +- hw/shix.c |2 +- hw/spapr.c|2 +- hw/spitz.c|8 ++-- hw/stellaris.c|4 +- hw/sun4m.c| 24 ++-- hw/sun4u.c|6 +- hw/tosa.c |2 +- hw/versatilepb.c |4 +- hw/vexpress.c |4 +- hw/virtex_ml507.c |2 +- hw/xen_machine_pv.c |2 +- hw/xtensa_lx60.c |4 +- hw/xtensa_sim.c |2 +- hw/z2.c |2 +- vl.c | 65 +-- 54 files changed, 184 insertions(+), 157 deletions(-)
Re: [Qemu-devel] [PATCH v2] net: add the support for -netdev socket, listen
On 02/18/2012 03:19 AM, zwu.ker...@gmail.com wrote: From: Zhi Yong Wuwu...@linux.vnet.ibm.com The -net socket,listen option does not work with the newer -netdev syntax: http://lists.gnu.org/archive/html/qemu-devel/2011-11/msg01508.html This patch makes it work now. Signed-off-by: Zhi Yong Wuwu...@linux.vnet.ibm.com --- net.c| 26 + net.h|2 + net/socket.c | 72 +- 3 files changed, 84 insertions(+), 16 deletions(-) diff --git a/net.c b/net.c index c34474f..60e7b35 100644 --- a/net.c +++ b/net.c @@ -190,6 +190,32 @@ static ssize_t qemu_deliver_packet_iov(VLANClientState *sender, int iovcnt, void *opaque); +VLANClientState *qemu_lookup_net_client(VLANState *vlan, +const char *name) +{ +VLANClientState *vc = NULL; + +if (vlan) { +QTAILQ_FOREACH(vc,vlan-clients, next) { +if (!strcmp(vc-name, name)) { +break; +} +} +} else { +QTAILQ_FOREACH(vc,non_vlan_clients, next) { +if (!strcmp(vc-name, name)) { +break; +} +} +} + +if (!vc) { +return NULL; +} + +return vc; +} + VLANClientState *qemu_new_net_client(NetClientInfo *info, VLANState *vlan, VLANClientState *peer, diff --git a/net.h b/net.h index 75a8c15..7f73160 100644 --- a/net.h +++ b/net.h @@ -90,6 +90,8 @@ struct VLANState { VLANState *qemu_find_vlan(int id, int allocate); VLANClientState *qemu_find_netdev(const char *id); +VLANClientState *qemu_lookup_net_client(VLANState *vlan, +const char *name); VLANClientState *qemu_new_net_client(NetClientInfo *info, VLANState *vlan, VLANClientState *peer, diff --git a/net/socket.c b/net/socket.c index d4c2002..3ecee59 100644 --- a/net/socket.c +++ b/net/socket.c @@ -43,6 +43,7 @@ typedef struct NetSocketState { } NetSocketState; typedef struct NetSocketListenState { +VLANClientState *nc; VLANState *vlan; char *model; char *name; @@ -247,7 +248,8 @@ static NetClientInfo net_dgram_socket_info = { static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, const char *model, const char *name, -int fd, int is_connected) +int fd, int is_connected, +int is_listen) { struct sockaddr_in saddr; int newfd; @@ -286,15 +288,28 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, } } -nc = qemu_new_net_client(net_dgram_socket_info, vlan, NULL, model, name); + +if (!is_listen || (is_listen !is_connected)) { +nc = qemu_new_net_client(net_dgram_socket_info, + vlan, NULL, model, name); +} else { +nc = qemu_lookup_net_client(vlan, name); +if (!nc) { +goto err; +} +} + +s = DO_UPCAST(NetSocketState, nc, nc); + +if (is_listen !is_connected) { +return s; +} snprintf(nc-info_str, sizeof(nc-info_str), socket: fd=%d (%s mcast=%s:%d), fd, is_connected ? cloned : , inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); -s = DO_UPCAST(NetSocketState, nc, nc); - s-fd = fd; qemu_set_fd_handler(s-fd, net_socket_send_dgram, NULL, s); @@ -325,16 +340,29 @@ static NetClientInfo net_socket_info = { static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, const char *model, const char *name, - int fd, int is_connected) + int fd, int is_connected, + int is_listen) { VLANClientState *nc; NetSocketState *s; -nc = qemu_new_net_client(net_socket_info, vlan, NULL, model, name); +if (!is_listen || (is_listen !is_connected)) { +nc = qemu_new_net_client(net_socket_info, vlan, NULL, model, name); +} else { +nc = qemu_lookup_net_client(vlan, name); +if (!nc) { +return NULL; +} +} + +s = DO_UPCAST(NetSocketState, nc, nc); + +if (is_listen !is_connected) { +return s; +} snprintf(nc-info_str, sizeof(nc-info_str), socket: fd=%d, fd); -s = DO_UPCAST(NetSocketState, nc, nc); s-fd = fd; @@ -348,7 +376,8 @@ static NetSocketState
Re: [Qemu-devel] [PATCH 5/5] boards: move all machine type functions to boards.c
Am 24.02.2012 15:13, schrieb Luiz Capitulino: The license text is the same as used in vl.c. Also note that it's necessary to make machine_parse() public. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- Makefile.target |3 +- hw/boards.c | 86 +++ hw/boards.h |1 + vl.c| 65 - 4 files changed, 89 insertions(+), 66 deletions(-) create mode 100644 hw/boards.c In anticipation of a board class derived from container I would rather have the file name match the class name, i.e. board.c. Unfortunately boards.h is used in quite a lot of places already, but when we QOM'ify it we might want to move it to include/qemu so all users would need to be touched anyway. diff --git a/Makefile.target b/Makefile.target index d5eb70d..dc76eba 100644 --- a/Makefile.target +++ b/Makefile.target @@ -195,7 +195,8 @@ endif #CONFIG_BSD_USER # System emulator target ifdef CONFIG_SOFTMMU -obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o +obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o \ + boards.o Please use obj-y += ... instead of the line break. Otherwise looks okay. Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH] qom: Make object_unref() free the object's memory when refcount goes to 0.
On 02/23/2012 10:21 AM, Alexander Barabash wrote: On 02/22/2012 09:12 PM, Anthony Liguori wrote: On 02/22/2012 12:00 PM, alexander_barab...@mentor.com wrote: From: Alexander Barabashalexander_barab...@mentor.com In the existing implementation, object_delete() calls object_unref(), then frees the object's storage. Running object_delete() on an object with reference count different from 1 causes program failure. In the existing implementation, object_unref() finalizes the object when its reference count becomes 0. In the new implementation, object_unref() finalizes and frees the object's storage when the reference count becomes 0. In the new implementation, object_delete() just calls object_unref(). Running object_delete() on an object with reference count different from 1 still causes program failure. This isn't correct. QOM objects don't necessarily have heap allocated objects. I've been thinking about this general problem and I think the right way to solve it is to have a delete notifier list. That way, object_new() can register a delete notifier that calls g_free() whenever refcount=0. That way an explicit object_delete() isn't needed anymore. Why do you want to have a delete notifier list, rather than just a delete callback. Because a notifier list allows for third parties to receive the event (think GObject signal/slots). At the point where refcount == 0, the destructor has been called already, so there is not much to be done, except for reclaim the memory. Right, but the memory is not allocated by the core of Object. This is important in order to allow in-place object creation. You could special case this and have a flag to indicate whether the object has allocated it's own memory or not but I think the two approaches end up having equal complexity whereas the NotifierList gives you a lot more flexibility. It makes it possible to use a small object allocator for Objects which could be useful one day if we use objects in a fast path (like using Objects to allocate packets in the network layer or requests in the block layer). Regards, Anthony Liguori Regards, Alex Although I think we should keep the call around as it's convenient for replacing occurrences of qdev_free() where you really want the assert. Regards, Anthony Liguori Signed-off-by: Alexander Barabashalexander_barab...@mentor.com --- qom/object.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qom/object.c b/qom/object.c index e6591e1..8d36a9c 100644 --- a/qom/object.c +++ b/qom/object.c @@ -373,9 +373,8 @@ Object *object_new(const char *typename) void object_delete(Object *obj) { + g_assert(obj-ref == 1); object_unref(obj); - g_assert(obj-ref == 0); - g_free(obj); } static bool type_is_ancestor(TypeImpl *type, TypeImpl *target_type) @@ -585,6 +584,7 @@ void object_unref(Object *obj) /* parent always holds a reference to its children */ if (obj-ref == 0) { object_finalize(obj); + g_free(obj); } }
Re: [Qemu-devel] [PATCH 3/5] boards: introduce machine_print_all()
On Fri, 24 Feb 2012 15:26:36 +0100 Andreas Färber afaer...@suse.de wrote: Am 24.02.2012 15:13, schrieb Luiz Capitulino: Print all registered machine types. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com I'm okay with the code movement, but is there a reason not to make it static? I can make it static. Needs a rebase due to 10 - 20 bump by Peter. Will rebase as soon as his patch is merged on master.
Re: [Qemu-devel] [PATCH 0/5]: Improve machine type functions
On Fri, 24 Feb 2012 08:58:55 -0600 Anthony Liguori aligu...@us.ibm.com wrote: On 02/24/2012 08:13 AM, Luiz Capitulino wrote: I was reading some related code yesterday and couldn't resist improving this. Not sure if this is aligned with any possible QOM work in this area, but I'm posting this anyway... I'm not sure how easy this is, but the way to do this with QOM would be: This seems like a cool thing to work on. The two major problems (for me at least) is testing and the possible huge amount of manual work, or do you think that most of the work can be automated? The problem with testing is that, we have a whole lot of machines I have no idea what's the best way of testing the conversion work. [...] That's not to say this series isn't a good cleanup. I haven't actually reviewed it yet. I just wanted to illustrate the next QOM steps. Ok. I honestly think that this series is a small first step. Even the QTAILQ conversion is worth it IMHO, because it clearly shows what the function is doing in a single line.
Re: [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ
Am 24.02.2012 15:56, schrieb Luiz Capitulino: On Fri, 24 Feb 2012 15:23:43 +0100 Andreas Färber afaer...@suse.de wrote: Am 24.02.2012 15:13, schrieb Luiz Capitulino: Signed-off-by: Luiz Capitulino lcapitul...@redhat.com Unless this fixes a bug, I'd rather not refactor this as in my head this is already just object_class_foreach() / object_class_by_name(), similar to CPUs on my qom-cpu branch. Is there a plan to convert this to qom anytime soon? I was planning to look into it after CPU is done, if no one beats me. Since CPU will touch on the machine init functions, doing both in parallel did not seem like a good idea to me. I consider both CPU and machine 1.1 material - if we can agree on the way there, then the code you are changing here will not see a release. It certainly doesn't hurt to commit it though. :) Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 5/5] boards: move all machine type functions to boards.c
On Fri, 24 Feb 2012 16:10:17 +0100 Andreas Färber afaer...@suse.de wrote: Am 24.02.2012 15:13, schrieb Luiz Capitulino: The license text is the same as used in vl.c. Also note that it's necessary to make machine_parse() public. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- Makefile.target |3 +- hw/boards.c | 86 +++ hw/boards.h |1 + vl.c| 65 - 4 files changed, 89 insertions(+), 66 deletions(-) create mode 100644 hw/boards.c In anticipation of a board class derived from container I would rather have the file name match the class name, i.e. board.c. Unfortunately boards.h is used in quite a lot of places already, but when we QOM'ify it we might want to move it to include/qemu so all users would need to be touched anyway. I don't min doing the rename work, but Anthony is talking about having a Machine type. So, maybe it's a better idea to do rename along with the QOM conversion, as that's when we'll be sure about the class name. diff --git a/Makefile.target b/Makefile.target index d5eb70d..dc76eba 100644 --- a/Makefile.target +++ b/Makefile.target @@ -195,7 +195,8 @@ endif #CONFIG_BSD_USER # System emulator target ifdef CONFIG_SOFTMMU -obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o +obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o \ + boards.o Please use obj-y += ... instead of the line break. Ok. Otherwise looks okay. Andreas
Re: [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ
On Fri, 24 Feb 2012 16:21:56 +0100 Andreas Färber afaer...@suse.de wrote: Am 24.02.2012 15:56, schrieb Luiz Capitulino: On Fri, 24 Feb 2012 15:23:43 +0100 Andreas Färber afaer...@suse.de wrote: Am 24.02.2012 15:13, schrieb Luiz Capitulino: Signed-off-by: Luiz Capitulino lcapitul...@redhat.com Unless this fixes a bug, I'd rather not refactor this as in my head this is already just object_class_foreach() / object_class_by_name(), similar to CPUs on my qom-cpu branch. Is there a plan to convert this to qom anytime soon? I was planning to look into it after CPU is done, if no one beats me. Since CPU will touch on the machine init functions, doing both in parallel did not seem like a good idea to me. I consider both CPU and machine 1.1 material - if we can agree on the way there, then the code you are changing here will not see a release. It certainly doesn't hurt to commit it though. :) Well, if you're already planning to do it I can drop the patch then.
Re: [Qemu-devel] [PATCH 00/19] Fix and improve chardev open error messages
On 02/07/2012 08:09 AM, Markus Armbruster wrote: Our chardev open error messages are an embarrassment. Commit 6e1db57b tried to improve the useless opening backend FOO failed message in qemu_chr_open_opts(), but it is flawed: some failure modes went from an unhelpful failed to an outright misleading error message (see first patch for details). And even for failure modes where the message isn't misleading, it's still sub-par. Clue: many backends already report their errors. The failed message is merely redundant then. Since I'm touching the error reporting anyway, convert it to error_report(), so that a future a monitor command to add character devices emits its errors to the monitor, not stderr. I've applied 1-8 and 14 as discussed in the mail exchange. I've still got the remaining patches in my review queue. Thanks, Anthony Liguori Outline: [01-04/19] Revert the flawed commit [05-06/19] Prepare for use of error_report() [07-17/19] Make the backends report decent errors on all failure paths [ 18/18] Rip out the useless failed message [ 19/19] Bonus fix: legacy chardev syntax error reporting Markus Armbruster (19): Revert qemu-char: Print strerror message on failure and deps qemu-char: Use qemu_open() to avoid leaking fds to children qemu-char: Re-apply style fixes from just reverted aad04cd0 qemu-char: qemu_chr_open_fd() can't fail, don't check vl.c: Error locations for options using add_device_config() gdbstub: Error locations for -gdb sockets: Drop sockets_debug debug code sockets: Clean up inet_listen_opts()'s convoluted bind() loop sockets: Chardev open error reporting, sockets part qemu-char: Chardev open error reporting, !_WIN32 part qemu-char: Chardev open error reporting, _WIN32 part qemu-char: Chardev open error reporting, tty part qemu-char: Chardev open error reporting, parport part console: Eliminate text_consoles[] console: Chardev open error reporting, console part spice-qemu-char: Chardev open error reporting, spicevmc part baum: Chardev open error reporting, braille part qemu-char: Chardev open error reporting, generic part qemu-char: Fix legacy chardev syntax error reporting console.c | 28 ++ console.h |2 +- hw/baum.c | 16 ++-- hw/baum.h |2 +- hw/msmouse.c |5 +- hw/msmouse.h |2 +- qemu-char.c | 263 ++--- qemu-sockets.c| 203 +++-- spice-qemu-char.c | 21 ++-- ui/qemu-spice.h |2 +- vl.c | 20 ++--- 11 files changed, 265 insertions(+), 299 deletions(-)
Re: [Qemu-devel] [PATCH 0/4] target-i386: Helpers for CPUID version
On 02/17/2012 10:46 AM, Andreas Färber wrote: Hello x86 gurus, This series came out of my qom-cpu work. The reasoning is that in a QOM world we will need this logic twice, once as before and once for -cpu family=x,model=y,stepping=z,model_id=foo. Note: The family=x value is not bounds-checked in cpu_x86_find_by_name()! I'd appreciate if someone could double-check the masks I added. I calculated them based on Intel® Processor Identification and the CPUID Instruction. Application Note 485. January 2011. Applied. Thanks. Regards, Anthony Liguori Thanks, Andreas Cc: Andre Przywaraandre.przyw...@amd.com Andreas Färber (4): target-i386: Introduce x86_cpuid_version_set_family() target-i386: Introduce x86_cpuid_version_set_model() target-i386: Introduce x86_cpuid_version_set_stepping() target-i386: Introduce x86_cpuid_set_model_id() target-i386/cpuid.c | 64 +++ 1 files changed, 44 insertions(+), 20 deletions(-)
Re: [Qemu-devel] [PATCH 0/7] cpu model bug fixes and definition corrections (v3)
On 02/17/2012 10:41 AM, Eduardo Habkost wrote: These are patches based on a series that John Cooper sent back in May 2011, and that I resent last June. Not all changes from that series are here, but just the most obvious ones. The previous submission of this series is: Message-Id:1307041990-26194-1-git-send-email-ehabk...@redhat.com http://marc.info/?l=qemu-develm=130704282917358 Eduardo Habkost (7): cpu models: reorder flag list to match bit order cpu flags: aliases: pclmuldq|pclmulqdq and ffxsr|fxsr_opt cpu defs: use Intel flag names for Intel models (v2) cpu defs: add pse36, mca, mtrr to AMD CPU definitions (v2) cpu defs: remove replicated flags from Intel (v2) add Westmere as a qemu cpu model (v2) cpu defs: uncomment empty extfeatures_ecx definition for Opteron_G1 (v2) sysconfigs/target/target-x86_64.conf | 52 + target-i386/cpuid.c |8 ++-- 2 files changed, 37 insertions(+), 23 deletions(-) Applied. Thanks. Regards, Anthony Liguori
Re: [Qemu-devel] [PATCH] split SCSI and LSI, add myself as SCSI maintainer
On 02/22/2012 08:59 AM, Paolo Bonzini wrote: This has been the de facto situation for a while now. Add a tree, too. Signed-off-by: Paolo Bonzinipbonz...@redhat.com Applied. Thanks. Regards, Anthony Liguori --- MAINTAINERS |9 +++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 647c413..0b3b3d8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -420,11 +420,16 @@ F: hw/pci* F: hw/piix* SCSI +M: Paolo Bonzinipbonz...@redhat.com +S: Supported +F: hw/virtio-scsi.* +F: hw/scsi* +T: git://github.com/bonzini/qemu.git scsi-next + +LSI53C895A M: Paul Brookp...@codesourcery.com -M: Kevin Wolfkw...@redhat.com S: Odd Fixes F: hw/lsi53c895a.c -F: hw/scsi* USB M: Gerd Hoffmannkra...@redhat.com
Re: [Qemu-devel] [PATCH] qom: In function object_set_link_property(), first call object_ref(), then object_unref().
On 02/22/2012 11:22 AM, alexander_barab...@mentor.com wrote: From: Alexander Barabashalexander_barab...@mentor.com In the old implementation, if the new value of the property links to the same object, as the old value, that object is first unref-ed, and then ref-ed. This leads to unintended deinitialization of that object. In the new implementation, this is fixed. Signed-off-by: Alexander Barabashalexander_barab...@mentor.com Applied. Thanks. Regards, Anthony Liguori --- qom/object.c | 11 +++ 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/qom/object.c b/qom/object.c index 941c291..e6591e1 100644 --- a/qom/object.c +++ b/qom/object.c @@ -892,6 +892,7 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { Object **child = opaque; +Object *old_target; bool ambiguous = false; const char *type; char *path; @@ -901,10 +902,8 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, visit_type_str(v,path, name, errp); -if (*child) { -object_unref(*child); -*child = NULL; -} +old_target = *child; +*child = NULL; if (strcmp(path, ) != 0) { Object *target; @@ -930,6 +929,10 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, } g_free(path); + +if (old_target != NULL) { +object_unref(old_target); +} } void object_property_add_link(Object *obj, const char *name,
Re: [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ
On Fri, 24 Feb 2012 15:23:43 +0100 Andreas Färber afaer...@suse.de wrote: Am 24.02.2012 15:13, schrieb Luiz Capitulino: Signed-off-by: Luiz Capitulino lcapitul...@redhat.com Unless this fixes a bug, I'd rather not refactor this as in my head this is already just object_class_foreach() / object_class_by_name(), similar to CPUs on my qom-cpu branch. Is there a plan to convert this to qom anytime soon? If there isn't, then I'd do the refactoring because the resulting code is simpler cleaner.
Re: [Qemu-devel] [PATCH 0/5]: Improve machine type functions
On 02/24/2012 09:20 AM, Luiz Capitulino wrote: On Fri, 24 Feb 2012 08:58:55 -0600 Anthony Liguorialigu...@us.ibm.com wrote: On 02/24/2012 08:13 AM, Luiz Capitulino wrote: I was reading some related code yesterday and couldn't resist improving this. Not sure if this is aligned with any possible QOM work in this area, but I'm posting this anyway... I'm not sure how easy this is, but the way to do this with QOM would be: This seems like a cool thing to work on. The two major problems (for me at least) is testing and the possible huge amount of manual work, Heh, I wouldn't quite call it huge :-) I think you can pretty easily sed the machine init function definitions to accept a Machine parameter as the first argument. I think to introduce the types, you would need to write a quick python script that parsed the QEMUMachine declarations and then converted that into a TypeInfo + class_init function. I wouldn't bother trying to make the code conversion script perfect. I've found it's easiest to convert the easy 90% automatically and then do the remaining 10% by hand. or do you think that most of the work can be automated? The problem with testing is that, we have a whole lot of machines I have no idea what's the best way of testing the conversion work. Since the conversion shouldn't change any logic, there shouldn't be a huge test burden. What I've done in the past is just write a little script that parses the output of -M ? and then walks through and executes qemu with no arguments other than -M $name. It's a bit tedious since you have to manually close the window but it's a relatively quick way to check each machine is behaving the same as it was before. Regards, Anthony Liguori [...] That's not to say this series isn't a good cleanup. I haven't actually reviewed it yet. I just wanted to illustrate the next QOM steps. Ok. I honestly think that this series is a small first step. Even the QTAILQ conversion is worth it IMHO, because it clearly shows what the function is doing in a single line.
[Qemu-devel] [PATCH 1/2] Add \n to the end of fatal spice error messages
Without it the shell prompt doesn't appear on a new line after qemu dies. --- ui/spice-core.c |8 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/spice-core.c b/ui/spice-core.c index 1308a3d..6d240a3 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -568,15 +568,15 @@ void qemu_spice_init(void) port = qemu_opt_get_number(opts, port, 0); tls_port = qemu_opt_get_number(opts, tls-port, 0); if (!port !tls_port) { -fprintf(stderr, neither port nor tls-port specified for spice.); +fprintf(stderr, neither port nor tls-port specified for spice.\n); exit(1); } if (port 0 || port 65535) { -fprintf(stderr, spice port is out of range); +fprintf(stderr, spice port is out of range\n); exit(1); } if (tls_port 0 || tls_port 65535) { -fprintf(stderr, spice tls-port is out of range); +fprintf(stderr, spice tls-port is out of range\n); exit(1); } password = qemu_opt_get(opts, password); @@ -700,7 +700,7 @@ void qemu_spice_init(void) qemu_opt_foreach(opts, add_channel, NULL, 0); if (0 != spice_server_init(spice_server, core_interface)) { -fprintf(stderr, failed to initialize spice server); +fprintf(stderr, failed to initialize spice server\n); exit(1); }; using_spice = 1; -- 1.7.7.6
[Qemu-devel] [PATCH 2/2] Error out when tls-channel option is used without TLS
It's currently possible to setup spice channels using TLS when no TLS port has been specified (ie TLS is disabled). This cannot work, so better to error out in such a situation. --- ui/spice-core.c |8 +++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/ui/spice-core.c b/ui/spice-core.c index 6d240a3..5e644c9 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -524,8 +524,11 @@ static int add_channel(const char *name, const char *value, void *opaque) { int security = 0; int rc; +int *tls_port = opaque; if (strcmp(name, tls-channel) == 0) { +if (!*tls_port) +return 1; security = SPICE_CHANNEL_SECURITY_SSL; } if (strcmp(name, plaintext-channel) == 0) { @@ -697,7 +700,10 @@ void qemu_spice_init(void) spice_server_set_playback_compression (spice_server, qemu_opt_get_bool(opts, playback-compression, 1)); -qemu_opt_foreach(opts, add_channel, NULL, 0); +if (qemu_opt_foreach(opts, add_channel, tls_port, 1) != 0) { +fprintf(stderr, tried to setup tls-channel without specifying a TLS port\n); +exit(1); +} if (0 != spice_server_init(spice_server, core_interface)) { fprintf(stderr, failed to initialize spice server\n); -- 1.7.7.6
Re: [Qemu-devel] [PATCH 5/5] qmp: add DEVICE_TRAY_MOVED event
On 02/23/2012 08:08 AM, Markus Armbruster wrote: Luiz Capitulinolcapitul...@redhat.com writes: On Thu, 23 Feb 2012 08:50:08 +0100 Markus Armbrusterarm...@redhat.com wrote: Kevin Wolfkw...@redhat.com writes: Am 17.02.2012 20:21, schrieb Luiz Capitulino: It's emitted whenever the tray is moved by the guest or by HMP/QMP commands. Signed-off-by: Luiz Capitulinolcapitul...@redhat.com --- QMP/qmp-events.txt | 18 ++ block.c| 24 monitor.c |3 +++ monitor.h |1 + 4 files changed, 46 insertions(+), 0 deletions(-) diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt index 06cb404..9286af5 100644 --- a/QMP/qmp-events.txt +++ b/QMP/qmp-events.txt @@ -26,6 +26,24 @@ Example: Note: If action is stop, a STOP event will eventually follow the BLOCK_IO_ERROR event. +DEVICE_TRAY_MOVED +- + +It's emitted whenever the tray of a removable device is moved by the guest +or by HMP/QMP commands. + +Data: + +- device: device name (json-string) For me, a device name is something related to qdev. 'device' is a misnomer consistently used in all QMP commands so far and we can't fix it any more, but at least the documentation should clarify what is meant (that's for a follow-up patch). We can fix it if we really want to: rename, then add the old name as alias for backward compatibility. Pick your favourite flavor of cruft. I like it, new events won't have the cruft. If we reserve device for device models, we need sensible names for device backends. One each for block, net and char. There's some precedence for blockdev, netdev, chardev, but they contain dev, so there's still some overloading of the name device. Better ideas? For 1.2 (when QOM is considered stable), this should become pathname. Given a path, a client can determine what the type of the object is (by reading the type property). In fact, I'd like to see all events have a pathname of origin. This would probably become part of the QMP protocol itself. This gives us a mechanism to subscribe to events from specific objects. Regards, Anthony Liguori
Re: [Qemu-devel] [PATCH][v14] megasas: LSI Megaraid SAS HBA emulation
On 24.02.2012, at 16:58, Anthony Liguori wrote: On 02/23/2012 09:34 AM, Michael S. Tsirkin wrote: On Tue, Feb 21, 2012 at 10:36:43AM +0100, Hannes Reinecke wrote: This patch adds an emulation for the LSI Megaraid SAS 8708EM2 HBA. I've tested it to work with Linux, Windows Vista, and Windows7. MSI-X support is currently broken; have to investigate. Changes since v13: - Remove separate MSI-X BAR - Simplify BAR allocation Changes since v12: - Fixup flag setting via properties - Fixup MSI-X handling - Disable MSI-X per default Changes since v11: - Remove unneeded variables Changes since v10: - Port to new device type API - Include suggestion from Alex Graf: - Remove 'inline' function declaration - Queue setup and interrupt enablement needs to be treated independently - Always read in 64 bit context and just mask out the top bits if required Changes since v9: - Split off trace events into a separate patch - Do not check for max_luns in PD Info - Update trace events - Clarify license statement - Fixup coding style issues Changes since v8: - Remove 'disable' keyword from trace definitions - Convert hand-crafted debugging statements with trace definitions - Treat 'context' tag as little endian Changes since v7: - Port to new memory API - Port to new PCI infrastructure - Use fixed buffers for sense processing - Update to updated SCSI infrastructure Changes since v6: - Preliminary patches pushed to Kevins block tree - Implement 64bit contexts, required for Windows7 - Use iovecs for DCMD processing - Add MSI-X support Latest Linux driver now happily uses MSI-X. - Static iovec allocation We have a fixed upper number of iovecs, so we can save us the allocation. Suggested by Alex Graf. - Update MFI header Latest Linux driver has some more definitions, add them - Fixup AEN handling - Update tracing details - Remove sdev pointer from megasas_cmd_t Changes since v5: - megasas: Use tracing infrastructure instead of DPRINTF - megasas: Use new PCI infrastructure - megasas: Check for iovec mapping failure cpu_map_physical_memory() might fail, so we need to check for it when mapping iovecs. - megasas: Trace scsi buffer overflow The transfer length as specified in the SCSI command might disagree with the length of the iovec. We should be tracing these issues. - megasas: Reset frames after init firmware When receiving an INIT FIRMWARE command we need reset all frames, otherwise some frames might point to invalid memory. Chances since v4: - megasas: checkpatch.pl fixes and update to work with the changed interface in scsi_req_new(). Also included the suggested fixes from Alex. Signed-off-by: Hannes Reineckeh...@suse.de Cc: Alexander Grafag...@suse.de Cc: Andreas Faerberafaer...@suse.de Cc: Gerhard Wiesingerli...@wiesinger.com So Alex asked whether I can merge this, which made me take a look. I don't know much about what this does so just general comments on all of the code. This should come through Paolo's new SCSI tree. And while I defended this before, I now think it really ought to be split after trying (and failing) to trim the bits below in Thunderbird. Split up in what pieces? The only natural split I could think of would be mfi.h and megasas.c. Splitting megasas.c inside of itself doesn't really make sense, as it's just a new device and useless when not complete. Alex
Re: [Qemu-devel] [PATCH 2/5] boards: rename machine type functions
On 24 February 2012 14:13, Luiz Capitulino lcapitul...@redhat.com wrote: Perform the following renames: o qemu_register_machine() - machine_register() o find_machine() - machine_find() o find_default_machine() - machine_find_default() Signed-off-by: Luiz Capitulino lcapitul...@redhat.com 52 files changed, 96 insertions(+), 96 deletions(-) I said I was going to nack the next change-whole-tree change, so here it is: nack. At some point we're going to have to actually start converting boards to be QOM objects themselves, but (a) I hope we can make that incremental so we can do things in batches the way we did with MemoryRegion conversions and (b) until then the qemu_register_machine rename just looks like unnecessary churn to me. -- PMM
Re: [Qemu-devel] [PATCH][v14] megasas: LSI Megaraid SAS HBA emulation
On 02/24/2012 10:05 AM, Alexander Graf wrote: So Alex asked whether I can merge this, which made me take a look. I don't know much about what this does so just general comments on all of the code. This should come through Paolo's new SCSI tree. And while I defended this before, I now think it really ought to be split after trying (and failing) to trim the bits below in Thunderbird. Split up in what pieces? The only natural split I could think of would be mfi.h and megasas.c. That would certainly help. Splitting megasas.c inside of itself doesn't really make sense, as it's just a new device and useless when not complete. That doesn't mean that splitting it isn't the right strategy. But I bet just pulling out mfi.h would make it a lot more reasonable to handle. Regards, Anthony Liguori
Re: [Qemu-devel] [PATCH 2/5] boards: rename machine type functions
On 02/24/2012 10:12 AM, Peter Maydell wrote: On 24 February 2012 14:13, Luiz Capitulinolcapitul...@redhat.com wrote: Perform the following renames: o qemu_register_machine() - machine_register() o find_machine() - machine_find() o find_default_machine() - machine_find_default() Signed-off-by: Luiz Capitulinolcapitul...@redhat.com 52 files changed, 96 insertions(+), 96 deletions(-) I said I was going to nack the next change-whole-tree change, so here it is: nack. At some point we're going to have to actually start converting boards to be QOM objects themselves, but (a) I hope we can make that incremental so we can do things in batches the way we did with MemoryRegion conversions and (b) until then the qemu_register_machine rename just looks like unnecessary churn to me. I think I agree with you here. I don't see the value compared to the churn here given that we're going to have to touch all of this again anyway soon. Regards, Anthony Liguori -- PMM
Re: [Qemu-devel] [PULL v4 00/18] virtio-scsi driver
On 02/22/2012 08:33 AM, Paolo Bonzini wrote: Anthony, the following changes since commit 99c7f87826337fa81f2f0f9baa9ca0a44faf90e9: input: send kbd+mouse events only to running guests. (2012-02-17 11:02:55 -0600) are available in the git repository at: git://github.com/bonzini/qemu.git virtio-scsi Kevin agreed on getting virtio-scsi in via a pull request, now that the code has been reviewed by Stefan Hajnoczi (virtio-scsi bits), Laszlo Ersek and Orit Wassermann. Laszlo and Orit found problems in patches 2 and 14, which are fixed in this pull request. In fact they reviewed almost all SCSI changes that went in since 0.15 (!) and found two bugs in scsi-bus.c, fixed in patches 16/17. Pulled. Thanks. Regards, Anthony Liguori Paolo Bonzini (16): dma-helpers: make QEMUSGList target independent dma-helpers: add dma_buf_read and dma_buf_write dma-helpers: add accounting wrappers ahci: use new DMA helpers scsi: pass residual amount to command_complete scsi: add scatter/gather functionality scsi-disk: enable scatter/gather functionality scsi: add SCSIDevice vmstate definitions scsi-generic: add migration support scsi-disk: add migration support virtio-scsi: add basic SCSI bus operation virtio-scsi: process control queue requests virtio-scsi: add migration support scsi: fix wrong return for target INQUIRY scsi: fix searching for an empty id scsi-block: always use scsi_generic_ops for cache != none Stefan Hajnoczi (2): virtio-scsi: Add virtio-scsi stub device virtio-scsi: Add basic request processing infrastructure Makefile.target |1 + default-configs/pci.mak |1 + default-configs/s390x-softmmu.mak |1 + dma-helpers.c | 37 +++ dma.h | 20 +- hw/esp.c |3 +- hw/ide/ahci.c | 82 + hw/lsi53c895a.c |2 +- hw/pci.h |1 + hw/s390-virtio-bus.c | 33 ++ hw/s390-virtio-bus.h |2 + hw/scsi-bus.c | 159 +- hw/scsi-disk.c| 138 +++-- hw/scsi-generic.c | 25 ++ hw/scsi.h | 22 ++- hw/spapr_vscsi.c |2 +- hw/usb-msd.c |2 +- hw/virtio-pci.c | 56 hw/virtio-pci.h |2 + hw/virtio-scsi.c | 617 + hw/virtio-scsi.h | 36 +++ hw/virtio.h |3 + 22 files changed, 1132 insertions(+), 113 deletions(-) create mode 100644 hw/virtio-scsi.c create mode 100644 hw/virtio-scsi.h
Re: [Qemu-devel] [PULL] Merge qemu-iotests into qemu.git
On 02/23/2012 03:48 AM, Kevin Wolf wrote: The following changes since commit 235fe3bfd46b1104575b540d0bc3fdf584030b99: qom: add test tools (2012-02-22 12:18:26 -0600) are available in the git repository at: git://repo.or.cz/qemu/kevin.git for-anthony Pulled. Thanks. Regards, Anthony Liguori Christoph Hellwig (10): qemu-iotests: Initial import into the public repository. qemu-iotests: skip test 005 for vpc format images qemu-iotests: add support for the vdi image format qemu-iotests: remove test image after 015 is done qemu-iotests: make a few more tests generic qemu-iotests: test I/O after EOF for growable files qemu-iotests: replace FSF postal addresses with www.gnu.org links qemu-iotests: test invalid pattern argument handling in qemu-io qemu-iotests: filter TEST_DIR correctly in 019 qemu-iotests: only run 016 for file and sheepdog protocols Josh Durgin (1): qemu-iotests: Update rbd support Kevin Wolf (21): qemu-iotests: add test for refcount table growth and snapshots qemu-iotests: simple backing file test qemu-iotests: test merge of backing file when converting qemu-iotests: test qemu-img convert with backing file for the output image qemu-iotests: test commiting changes to backing file qemu-iotests: common.pattern: allow spaces in io() operation qemu-iotests: test bdrv_load/save_vmstate qemu-iotests: fix expected result for 019 after qemu-io change qemu-iotests: align test requests according to cluster size qemu-iotests: 019: Make cluster size dynamic qemu-iotests: test larger clusters sizes on qcow2 qemu-iotests: test qemu-img rebase qemu-iotests: improve rebase test qemu-iotests: qcow2 error path tests qemu-iotests: consider more cases in parsing qemu-io output qemu-iotests: improve test for qemu-img convert with backing file qemu-iotests: update expected results after qemu-img changes qemu-iotests: fix 019 golden output qemu-iotests: Update filter for default cluster size qemu-iotests: test loading internal snapshots Merge qemu-iotests into for-anthony Lucas Meneghel Rodrigues (2): qemu-iotests: check: print relevant path information qemu-iotests: common.config: Allow use of arbitrary qemu* paths MORITA Kazutaka (1): qemu-iotests: add support for rbd and sheepdog protocols Mitnick Lyu (1): qemu-iotests: common.config: Fix no $TEST_DIR directory Stefan Hajnoczi (8): qemu-iotests: explicitly use bash interpreter qemu-iotests: test bdrv_truncate qemu-iotests: add sub-cluster allocating write test for sparse image formats qemu-iotests: add read/write from smaller backing image test qemu-iotests: add support for qed format qemu-iotests: filter IMGFMT correctly in 019 qemu-iotests: Use zero-based offsets for IO patterns qemu-iotests: add qed support to 025 image resize test Stefan Weil (3): qemu-iotests: fix pattern for write test qemu-iotests: add support for vdi format static option qemu-iotests: README: Fix spelling tests/qemu-iotests/.gitignore |7 + tests/qemu-iotests/001| 65 + tests/qemu-iotests/001.out| 15 + tests/qemu-iotests/002| 72 + tests/qemu-iotests/002.out| 23 + tests/qemu-iotests/003| 78 + tests/qemu-iotests/003.out| 23 + tests/qemu-iotests/004| 104 + tests/qemu-iotests/004.out| 41 + tests/qemu-iotests/005| 73 + tests/qemu-iotests/005.out| 13 + tests/qemu-iotests/006| 54 + tests/qemu-iotests/006.out|6 + tests/qemu-iotests/007| 67 + tests/qemu-iotests/007.out| 18 + tests/qemu-iotests/008| 65 + tests/qemu-iotests/008.out| 15 + tests/qemu-iotests/009| 69 + tests/qemu-iotests/009.out| 18 + tests/qemu-iotests/010| 71 + tests/qemu-iotests/010.out| 22 + tests/qemu-iotests/011| 75 + tests/qemu-iotests/011.out| 50 + tests/qemu-iotests/012| 62 + tests/qemu-iotests/012.out|9 + tests/qemu-iotests/013| 98 + tests/qemu-iotests/013.out|43983 + tests/qemu-iotests/014| 77 + tests/qemu-iotests/014.out|64074 + tests/qemu-iotests/015| 85 + tests/qemu-iotests/015.out| 20 + tests/qemu-iotests/016| 70 + tests/qemu-iotests/016.out| 23 + tests/qemu-iotests/017| 101 + tests/qemu-iotests/017.out| 1077 + tests/qemu-iotests/018| 104 + tests/qemu-iotests/018.out| 1077 + tests/qemu-iotests/019| 129
Re: [Qemu-devel] [PULL 0/5]: QMP queue
On 02/23/2012 08:42 AM, Luiz Capitulino wrote: Contains only the DEVICE_TRAY_MOVED event series. The changes (since 235fe3bfd46b1104575b540d0bc3fdf584030b99) are available in the following repository: git://repo.or.cz/qemu/qmp-unstable.git queue/qmp Pulled. Thanks. Regards, Anthony Liguori Luiz Capitulino (5): block: Rename bdrv_mon_event() BlockMonEventAction block: bdrv_eject(): Make eject_flag a real bool block: Don't call bdrv_eject() if the tray state didn't change ide: drop ide_tray_state_post_load() qmp: add DEVICE_TRAY_MOVED event QMP/qmp-events.txt | 18 +++ block.c| 84 +-- block.h|8 ++-- block/raw-posix.c |6 ++-- block/raw.c|2 +- block_int.h|2 +- hw/ide/atapi.c |7 +++- hw/ide/core.c | 16 ++ hw/scsi-disk.c | 13 +--- hw/virtio-blk.c|6 ++-- monitor.c |3 ++ monitor.h |1 + 12 files changed, 104 insertions(+), 62 deletions(-)
Re: [Qemu-devel] [PULL] Zynq-7000 EPP platform model
On 02/20/2012 12:25 AM, Peter Crosthwaite wrote: Pull Request for Zynq-7000 platform model initial support. The following changes since commit 99c7f87826337fa81f2f0f9baa9ca0a44faf90e9: input: send kbd+mouse events only to running guests. (2012-02-17 11:02:55 -0600) are available in the git repository at: git://developer.petalogix.com/private/peterc/qemu.git zynq-initial.6 Peter A. G. Crosthwaite (4): cadence_uart: initial version of device model cadence_ttc: initial version of device model cadence_gem: initial version of device model xilinx_zynq: machine model initial version MAINTAINERS |5 + Makefile.target |4 + hw/cadence_gem.c | 1229 ++ hw/cadence_ttc.c | 439 ++ hw/cadence_uart.c| 559 +++ hw/xilinx_zynq.c | 173 +++ hw/zynq_arm_sysctl.c | 532 ++ I'd prefer this comes through Peter's tree for now. If Peter wants to pull from you into his tree, I'm okay with that. Regards, Anthony Liguori
Re: [Qemu-devel] [PATCH 5/5] qmp: add DEVICE_TRAY_MOVED event
On Fri, 24 Feb 2012 10:01:00 -0600 Anthony Liguori anth...@codemonkey.ws wrote: On 02/23/2012 08:08 AM, Markus Armbruster wrote: Luiz Capitulinolcapitul...@redhat.com writes: On Thu, 23 Feb 2012 08:50:08 +0100 Markus Armbrusterarm...@redhat.com wrote: Kevin Wolfkw...@redhat.com writes: Am 17.02.2012 20:21, schrieb Luiz Capitulino: It's emitted whenever the tray is moved by the guest or by HMP/QMP commands. Signed-off-by: Luiz Capitulinolcapitul...@redhat.com --- QMP/qmp-events.txt | 18 ++ block.c| 24 monitor.c |3 +++ monitor.h |1 + 4 files changed, 46 insertions(+), 0 deletions(-) diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt index 06cb404..9286af5 100644 --- a/QMP/qmp-events.txt +++ b/QMP/qmp-events.txt @@ -26,6 +26,24 @@ Example: Note: If action is stop, a STOP event will eventually follow the BLOCK_IO_ERROR event. +DEVICE_TRAY_MOVED +- + +It's emitted whenever the tray of a removable device is moved by the guest +or by HMP/QMP commands. + +Data: + +- device: device name (json-string) For me, a device name is something related to qdev. 'device' is a misnomer consistently used in all QMP commands so far and we can't fix it any more, but at least the documentation should clarify what is meant (that's for a follow-up patch). We can fix it if we really want to: rename, then add the old name as alias for backward compatibility. Pick your favourite flavor of cruft. I like it, new events won't have the cruft. If we reserve device for device models, we need sensible names for device backends. One each for block, net and char. There's some precedence for blockdev, netdev, chardev, but they contain dev, so there's still some overloading of the name device. Better ideas? For 1.2 (when QOM is considered stable), this should become pathname. Given a path, a client can determine what the type of the object is (by reading the type property). In fact, I'd like to see all events have a pathname of origin. This would probably become part of the QMP protocol itself. This gives us a mechanism to subscribe to events from specific objects. This is 1.2 material, right? I'm asking because the conversion of events to the qapi is not too far away, but I think that using QOM will somewhat deprecate the code you have in the glib branch (besides having to wait for 1.2)?
Re: [Qemu-devel] [PATCH 5/5] qmp: add DEVICE_TRAY_MOVED event
On 02/24/2012 10:39 AM, Luiz Capitulino wrote: On Fri, 24 Feb 2012 10:01:00 -0600 Anthony Liguorianth...@codemonkey.ws wrote: On 02/23/2012 08:08 AM, Markus Armbruster wrote: Luiz Capitulinolcapitul...@redhat.com writes: On Thu, 23 Feb 2012 08:50:08 +0100 Markus Armbrusterarm...@redhat.com wrote: Kevin Wolfkw...@redhat.com writes: Am 17.02.2012 20:21, schrieb Luiz Capitulino: It's emitted whenever the tray is moved by the guest or by HMP/QMP commands. Signed-off-by: Luiz Capitulinolcapitul...@redhat.com --- QMP/qmp-events.txt | 18 ++ block.c| 24 monitor.c |3 +++ monitor.h |1 + 4 files changed, 46 insertions(+), 0 deletions(-) diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt index 06cb404..9286af5 100644 --- a/QMP/qmp-events.txt +++ b/QMP/qmp-events.txt @@ -26,6 +26,24 @@ Example: Note: If action is stop, a STOP event will eventually follow the BLOCK_IO_ERROR event. +DEVICE_TRAY_MOVED +- + +It's emitted whenever the tray of a removable device is moved by the guest +or by HMP/QMP commands. + +Data: + +- device: device name (json-string) For me, a device name is something related to qdev. 'device' is a misnomer consistently used in all QMP commands so far and we can't fix it any more, but at least the documentation should clarify what is meant (that's for a follow-up patch). We can fix it if we really want to: rename, then add the old name as alias for backward compatibility. Pick your favourite flavor of cruft. I like it, new events won't have the cruft. If we reserve device for device models, we need sensible names for device backends. One each for block, net and char. There's some precedence for blockdev, netdev, chardev, but they contain dev, so there's still some overloading of the name device. Better ideas? For 1.2 (when QOM is considered stable), this should become pathname. Given a path, a client can determine what the type of the object is (by reading the type property). In fact, I'd like to see all events have a pathname of origin. This would probably become part of the QMP protocol itself. This gives us a mechanism to subscribe to events from specific objects. This is 1.2 material, right? Yes. I'm asking because the conversion of events to the qapi is not too far away, but I think that using QOM will somewhat deprecate the code you have in the glib branch (besides having to wait for 1.2)? I have some vague ideas about what to do here. One thought would be to have a standard notifier mechanism in Object that was advertised as a property type. We could then provide an interface via QMP to [un]subscribe to a notifier property. I won't get to this until the 1.2 time frame though. My goals for 1.1 are to get qbus conversions merged and refactor IRQs/MemoryRegions to use QOM. If time permits, also refactor the PC to better use QOM. If someone wants to tackle events in QOM, I'd be happy to provide some suggestions on where to start. Regards, Anthony Liguori Regards, Anthony Liguori
Re: [Qemu-devel] [PATCH 1/2] Add \n to the end of fatal spice error messages
On 02/24/12 11:37, Christophe Fergeau wrote: Without it the shell prompt doesn't appear on a new line after qemu dies. --- ui/spice-core.c |8 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/spice-core.c b/ui/spice-core.c index 1308a3d..6d240a3 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -568,15 +568,15 @@ void qemu_spice_init(void) port = qemu_opt_get_number(opts, port, 0); tls_port = qemu_opt_get_number(opts, tls-port, 0); if (!port !tls_port) { -fprintf(stderr, neither port nor tls-port specified for spice.); +fprintf(stderr, neither port nor tls-port specified for spice.\n); Even better is this (no newline needed here): error_report(neither port nor tls-port specified fo spice.); exit(1); } if (port 0 || port 65535) { -fprintf(stderr, spice port is out of range); +fprintf(stderr, spice port is out of range\n); exit(1); } if (tls_port 0 || tls_port 65535) { -fprintf(stderr, spice tls-port is out of range); +fprintf(stderr, spice tls-port is out of range\n); exit(1); } password = qemu_opt_get(opts, password); @@ -700,7 +700,7 @@ void qemu_spice_init(void) qemu_opt_foreach(opts, add_channel, NULL, 0); if (0 != spice_server_init(spice_server, core_interface)) { -fprintf(stderr, failed to initialize spice server); +fprintf(stderr, failed to initialize spice server\n); exit(1); }; using_spice = 1;
Re: [Qemu-devel] [PULL 0/3] Trivial patches for 11 to 24 February 2012
On 02/24/2012 08:00 AM, Stefan Hajnoczi wrote: The following changes since commit 235fe3bfd46b1104575b540d0bc3fdf584030b99: qom: add test tools (2012-02-22 12:18:26 -0600) are available in the git repository at: git://github.com/stefanha/qemu.git trivial-patches for you to fetch changes up to f293d8b1f26953ccaef794785cea0619d4f8c268: slirp/misc: fix gcc __warn_memset_zero_len warnings (2012-02-24 13:24:42 +) Pulled. Thanks. Regards, Anthony Liguori Alon Levy (1): slirp/misc: fix gcc __warn_memset_zero_len warnings Peter Maydell (1): vl.c: Increase width of machine name column in -M ? output Stefan Weil (1): tcg: Remove unneeded include statements slirp/misc.c | 21 +++-- tcg/tcg.c| 12 vl.c |4 ++-- 3 files changed, 9 insertions(+), 28 deletions(-)
Re: [Qemu-devel] [PATCH 2/2] Error out when tls-channel option is used without TLS
On 02/24/12 11:37, Christophe Fergeau wrote: It's currently possible to setup spice channels using TLS when no TLS port has been specified (ie TLS is disabled). This cannot work, so better to error out in such a situation. --- ui/spice-core.c |8 +++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/ui/spice-core.c b/ui/spice-core.c index 6d240a3..5e644c9 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -524,8 +524,11 @@ static int add_channel(const char *name, const char *value, void *opaque) { int security = 0; int rc; +int *tls_port = opaque; if (strcmp(name, tls-channel) == 0) { +if (!*tls_port) The error message should be printed here ... +return 1; security = SPICE_CHANNEL_SECURITY_SSL; } if (strcmp(name, plaintext-channel) == 0) { @@ -697,7 +700,10 @@ void qemu_spice_init(void) spice_server_set_playback_compression (spice_server, qemu_opt_get_bool(opts, playback-compression, 1)); -qemu_opt_foreach(opts, add_channel, NULL, 0); +if (qemu_opt_foreach(opts, add_channel, tls_port, 1) != 0) { +fprintf(stderr, tried to setup tls-channel without specifying a TLS port\n); +exit(1); ... otherwise we'll get a misleading error message in case add_channel() happens fail for another reason. cheers, Gerd
[Qemu-devel] [PATCH 1/2 v2] Add blkmirror block driver
From: Marcelo Tosatti mtosa...@redhat.com Mirrored writes are used by live block copy. Signed-off-by: Marcelo Tosatti mtosa...@redhat.com Signed-off-by: Federico Simoncelli fsimo...@redhat.com --- Makefile.objs |2 +- block/blkmirror.c | 247 docs/blkmirror.txt | 16 3 files changed, 264 insertions(+), 1 deletions(-) create mode 100644 block/blkmirror.c create mode 100644 docs/blkmirror.txt diff --git a/Makefile.objs b/Makefile.objs index 67ee3df..6020308 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -34,7 +34,7 @@ block-nested-y += raw.o cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vv block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-cache.o block-nested-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o block-nested-y += qed-check.o -block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o +block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o blkmirror.o block-nested-y += stream.o block-nested-$(CONFIG_WIN32) += raw-win32.o block-nested-$(CONFIG_POSIX) += raw-posix.o diff --git a/block/blkmirror.c b/block/blkmirror.c new file mode 100644 index 000..49e3381 --- /dev/null +++ b/block/blkmirror.c @@ -0,0 +1,247 @@ +/* + * Block driver for mirrored writes. + * + * Copyright (C) 2011 Red Hat, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include stdarg.h +#include block_int.h + +typedef struct { +BlockDriverState *bs[2]; +} BdrvMirrorState; + +typedef struct DupAIOCB DupAIOCB; + +typedef struct SingleAIOCB { +BlockDriverAIOCB *aiocb; +int finished; +DupAIOCB *parent; +} SingleAIOCB; + +struct DupAIOCB { +BlockDriverAIOCB common; +int count; + +BlockDriverCompletionFunc *cb; +SingleAIOCB aios[2]; +int ret; +}; + +/* Valid blkmirror filenames look like + * blkmirror:path/to/image1:path/to/image2 */ +static int blkmirror_open(BlockDriverState *bs, const char *filename, int flags) +{ +BdrvMirrorState *m = bs-opaque; +int ret, escape, i, n; +char *filename2; + +/* Parse the blkmirror: prefix */ +if (strncmp(filename, blkmirror:, strlen(blkmirror:))) { +return -EINVAL; +} +filename += strlen(blkmirror:); + +/* Parse the raw image filename */ +filename2 = g_malloc(strlen(filename)+1); +escape = 0; +for (i = n = 0; i strlen(filename); i++) { +if (!escape filename[i] == ':') { +break; +} +if (!escape filename[i] == '\\') { +escape = 1; +} else { +escape = 0; +} + +if (!escape) { +filename2[n++] = filename[i]; +} +} +filename2[n] = '\0'; + +m-bs[0] = bdrv_new(); +if (m-bs[0] == NULL) { +g_free(filename2); +return -ENOMEM; +} +ret = bdrv_open(m-bs[0], filename2, flags, NULL); +g_free(filename2); +if (ret 0) { +return ret; +} +filename += i + 1; + +m-bs[1] = bdrv_new(); +if (m-bs[1] == NULL) { +bdrv_delete(m-bs[0]); +return -ENOMEM; +} +ret = bdrv_open(m-bs[1], filename, flags | BDRV_O_NO_BACKING, NULL); +if (ret 0) { +bdrv_delete(m-bs[0]); +return ret; +} + +return 0; +} + +static void blkmirror_close(BlockDriverState *bs) +{ +BdrvMirrorState *m = bs-opaque; +int i; + +for (i = 0; i 2; i++) { +bdrv_delete(m-bs[i]); +m-bs[i] = NULL; +} +} + +static coroutine_fn int blkmirror_co_flush(BlockDriverState *bs) +{ +BdrvMirrorState *m = bs-opaque; +int ret; + +ret = bdrv_co_flush(m-bs[0]); +if (ret 0) { +return ret; +} + +return bdrv_co_flush(m-bs[1]); +} + +static int64_t blkmirror_getlength(BlockDriverState *bs) +{ +BdrvMirrorState *m = bs-opaque; + +return bdrv_getlength(m-bs[0]); +} + +static BlockDriverAIOCB *blkmirror_aio_readv(BlockDriverState *bs, + int64_t sector_num, + QEMUIOVector *qiov, + int nb_sectors, + BlockDriverCompletionFunc *cb, + void *opaque) +{ +BdrvMirrorState *m = bs-opaque; +return bdrv_aio_readv(m-bs[0], sector_num, qiov, nb_sectors, cb, opaque); +} + +static void dup_aio_cancel(BlockDriverAIOCB *blockacb) +{ +DupAIOCB *acb = container_of(blockacb, DupAIOCB, common); +int i; + +for (i = 0 ; i 2; i++) { +if (!acb-aios[i].finished) { +bdrv_aio_cancel(acb-aios[i].aiocb); +} +} +qemu_aio_release(acb); +} + +static AIOPool dup_aio_pool = { +.aiocb_size = sizeof(DupAIOCB), +.cancel = dup_aio_cancel, +}; + +static void blkmirror_aio_cb(void
[Qemu-devel] [PATCH 2/2 v2] Add the blockdev-reopen and blockdev-migrate commands
Signed-off-by: Federico Simoncelli fsimo...@redhat.com --- blockdev.c | 107 -- hmp-commands.hx | 38 +++ hmp.c| 24 hmp.h|2 + qapi-schema.json | 54 +++ 5 files changed, 213 insertions(+), 12 deletions(-) diff --git a/blockdev.c b/blockdev.c index 2c132a3..f51bd6f 100644 --- a/blockdev.c +++ b/blockdev.c @@ -646,9 +646,8 @@ void do_commit(Monitor *mon, const QDict *qdict) } } -void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, -bool has_format, const char *format, -Error **errp) +static void change_blockdev_image(const char *device, const char *new_image_file, + const char *format, bool create, Error **errp) { BlockDriverState *bs; BlockDriver *drv, *old_drv, *proto_drv; @@ -671,7 +670,7 @@ void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, old_drv = bs-drv; flags = bs-open_flags; -if (!has_format) { +if (!format) { format = qcow2; } @@ -681,24 +680,26 @@ void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, return; } -proto_drv = bdrv_find_protocol(snapshot_file); +proto_drv = bdrv_find_protocol(new_image_file); if (!proto_drv) { error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); return; } -ret = bdrv_img_create(snapshot_file, format, bs-filename, - bs-drv-format_name, NULL, -1, flags); -if (ret) { -error_set(errp, QERR_UNDEFINED_ERROR); -return; +if (create) { +ret = bdrv_img_create(new_image_file, format, bs-filename, + bs-drv-format_name, NULL, -1, flags); +if (ret) { +error_set(errp, QERR_UNDEFINED_ERROR); +return; +} } bdrv_drain_all(); bdrv_flush(bs); bdrv_close(bs); -ret = bdrv_open(bs, snapshot_file, flags, drv); +ret = bdrv_open(bs, new_image_file, flags, drv); /* * If reopening the image file we just created fails, fall back * and try to re-open the original image. If that fails too, we @@ -709,11 +710,93 @@ void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, if (ret != 0) { error_set(errp, QERR_OPEN_FILE_FAILED, old_filename); } else { -error_set(errp, QERR_OPEN_FILE_FAILED, snapshot_file); +error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file); } } } +void qmp_drive_reopen(const char *device, const char *new_image_file, + bool has_format, const char *format, Error **errp) +{ +change_blockdev_image(device, new_image_file, + has_format ? format : NULL, false, errp); +} + +void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, +bool has_format, const char *format, +Error **errp) +{ +change_blockdev_image(device, snapshot_file, + has_format ? format : NULL, true, errp); +} + +static void qmp_blockdev_mirror(const char *device, const char *destination, +const char *new_image_file, Error **errp) +{ +BlockDriver *drv; +int i, j, escape; +char new_filename[2048], *filename; + +drv = bdrv_find_format(blkmirror); +if (!drv) { +error_set(errp, QERR_INVALID_BLOCK_FORMAT, blkmirror); +return; +} + +escape = 0; +for (i = 0, j = 0; j strlen(new_image_file); j++) { + loop: +if (!(i sizeof(new_filename) - 2)) { +error_set(errp, QERR_INVALID_PARAMETER_VALUE, + new-image-file, shorter filename); +return; +} + +if (new_image_file[j] == ':' || new_image_file[j] == '\\') { +if (!escape) { +new_filename[i++] = '\\', escape = 1; +goto loop; +} else { +escape = 0; +} +} + +new_filename[i++] = new_image_file[j]; +} + +filename = g_strdup_printf(blkmirror:%s:%s, new_filename, destination); +change_blockdev_image(device, filename, blkmirror, false, errp); +g_free(filename); +} + +void qmp_blockdev_migrate(const char *device, bool incremental, + const char *destination, bool has_new_image_file, + const char *new_image_file, Error **errp) +{ +BlockDriverState *bs; + +bs = bdrv_find(device); +if (!bs) { +error_set(errp, QERR_DEVICE_NOT_FOUND, device); +return; +} +if (bdrv_in_use(bs)) { +error_set(errp, QERR_DEVICE_IN_USE, device); +return; +} + +if (incremental) { +if
Re: [Qemu-devel] [PATCH v2] net: add the support for -netdev socket, listen
On Fri, Feb 24, 2012 at 11:05 PM, Anthony Liguori aligu...@us.ibm.com wrote: On 02/18/2012 03:19 AM, zwu.ker...@gmail.com wrote: From: Zhi Yong Wuwu...@linux.vnet.ibm.com The -net socket,listen option does not work with the newer -netdev syntax: http://lists.gnu.org/archive/html/qemu-devel/2011-11/msg01508.html This patch makes it work now. Signed-off-by: Zhi Yong Wuwu...@linux.vnet.ibm.com --- net.c | 26 + net.h | 2 + net/socket.c | 72 +- 3 files changed, 84 insertions(+), 16 deletions(-) diff --git a/net.c b/net.c index c34474f..60e7b35 100644 --- a/net.c +++ b/net.c @@ -190,6 +190,32 @@ static ssize_t qemu_deliver_packet_iov(VLANClientState *sender, int iovcnt, void *opaque); +VLANClientState *qemu_lookup_net_client(VLANState *vlan, + const char *name) +{ + VLANClientState *vc = NULL; + + if (vlan) { + QTAILQ_FOREACH(vc,vlan-clients, next) { + if (!strcmp(vc-name, name)) { + break; + } + } + } else { + QTAILQ_FOREACH(vc,non_vlan_clients, next) { + if (!strcmp(vc-name, name)) { + break; + } + } + } + + if (!vc) { + return NULL; + } + + return vc; +} + VLANClientState *qemu_new_net_client(NetClientInfo *info, VLANState *vlan, VLANClientState *peer, diff --git a/net.h b/net.h index 75a8c15..7f73160 100644 --- a/net.h +++ b/net.h @@ -90,6 +90,8 @@ struct VLANState { VLANState *qemu_find_vlan(int id, int allocate); VLANClientState *qemu_find_netdev(const char *id); +VLANClientState *qemu_lookup_net_client(VLANState *vlan, + const char *name); VLANClientState *qemu_new_net_client(NetClientInfo *info, VLANState *vlan, VLANClientState *peer, diff --git a/net/socket.c b/net/socket.c index d4c2002..3ecee59 100644 --- a/net/socket.c +++ b/net/socket.c @@ -43,6 +43,7 @@ typedef struct NetSocketState { } NetSocketState; typedef struct NetSocketListenState { + VLANClientState *nc; VLANState *vlan; char *model; char *name; @@ -247,7 +248,8 @@ static NetClientInfo net_dgram_socket_info = { static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, const char *model, const char *name, - int fd, int is_connected) + int fd, int is_connected, + int is_listen) { struct sockaddr_in saddr; int newfd; @@ -286,15 +288,28 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, } } - nc = qemu_new_net_client(net_dgram_socket_info, vlan, NULL, model, name); + + if (!is_listen || (is_listen !is_connected)) { + nc = qemu_new_net_client(net_dgram_socket_info, + vlan, NULL, model, name); + } else { + nc = qemu_lookup_net_client(vlan, name); + if (!nc) { + goto err; + } + } + + s = DO_UPCAST(NetSocketState, nc, nc); + + if (is_listen !is_connected) { + return s; + } snprintf(nc-info_str, sizeof(nc-info_str), socket: fd=%d (%s mcast=%s:%d), fd, is_connected ? cloned : , inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); - s = DO_UPCAST(NetSocketState, nc, nc); - s-fd = fd; qemu_set_fd_handler(s-fd, net_socket_send_dgram, NULL, s); @@ -325,16 +340,29 @@ static NetClientInfo net_socket_info = { static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, const char *model, const char *name, - int fd, int is_connected) + int fd, int is_connected, + int is_listen) { VLANClientState *nc; NetSocketState *s; - nc = qemu_new_net_client(net_socket_info, vlan, NULL, model, name); + if (!is_listen || (is_listen !is_connected)) { + nc = qemu_new_net_client(net_socket_info, vlan, NULL, model, name); + } else { + nc = qemu_lookup_net_client(vlan, name); + if (!nc) { + return NULL; + } + } + + s = DO_UPCAST(NetSocketState, nc, nc); + + if (is_listen !is_connected) { + return s; + }
Re: [Qemu-devel] [PATCH 2/5] boards: rename machine type functions
On Fri, 24 Feb 2012 10:15:52 -0600 Anthony Liguori aligu...@us.ibm.com wrote: On 02/24/2012 10:12 AM, Peter Maydell wrote: On 24 February 2012 14:13, Luiz Capitulinolcapitul...@redhat.com wrote: Perform the following renames: o qemu_register_machine() - machine_register() o find_machine() - machine_find() o find_default_machine() - machine_find_default() Signed-off-by: Luiz Capitulinolcapitul...@redhat.com 52 files changed, 96 insertions(+), 96 deletions(-) I said I was going to nack the next change-whole-tree change, so here it is: nack. At some point we're going to have to actually start converting boards to be QOM objects themselves, but (a) I hope we can make that incremental so we can do things in batches the way we did with MemoryRegion conversions and (b) until then the qemu_register_machine rename just looks like unnecessary churn to me. I think I agree with you here. I don't see the value compared to the churn here given that we're going to have to touch all of this again anyway soon. Do you guys see value in patch 5/5, which moves the machine function to the boards file? If you don't I'll keep only patch 1/5 (which can be submitted to qemu-trivial).
Re: [Qemu-devel] [PULL 0/8] qemu-ga: add support for Windows
On 02/23/2012 04:10 PM, Michael Roth wrote: The following changes since commit 235fe3bfd46b1104575b540d0bc3fdf584030b99: qom: add test tools (2012-02-22 12:18:26 -0600) are available in the git repository at: git://github.com/mdroth/qemu.git qga-win32-pull-2-23-12 Pulled. Thanks. Regards, Anthony Liguori Michael Roth (8): qemu-ga: Add schema documentation for types qemu-ga: move channel/transport functionality into wrapper class qemu-ga: separate out common commands from posix-specific ones qemu-ga: rename guest-agent-commands.c - commands-posix.c qemu-ga: fixes for win32 build of qemu-ga qemu-ga: add initial win32 support qemu-ga: add Windows service integration qemu-ga: add win32 guest-shutdown command Makefile |2 +- Makefile.objs|8 +- configure|2 +- qapi-schema-guest.json | 118 +- qemu-ga.c| 423 ++ qga/channel-posix.c | 246 + qga/channel-win32.c | 340 + qga/channel.h| 33 ++ qga/{guest-agent-commands.c = commands-posix.c} | 59 +--- qga/commands-win32.c | 130 +++ qga/commands.c | 73 qga/guest-agent-core.h |3 +- qga/service-win32.c | 114 ++ qga/service-win32.h | 30 ++ 14 files changed, 1263 insertions(+), 318 deletions(-) create mode 100644 qga/channel-posix.c create mode 100644 qga/channel-win32.c create mode 100644 qga/channel.h rename qga/{guest-agent-commands.c = commands-posix.c} (89%) create mode 100644 qga/commands-win32.c create mode 100644 qga/commands.c create mode 100644 qga/service-win32.c create mode 100644 qga/service-win32.h
Re: [Qemu-devel] [PATCH 5/5] qmp: add DEVICE_TRAY_MOVED event
On Fri, 24 Feb 2012 10:44:11 -0600 Anthony Liguori anth...@codemonkey.ws wrote: I'm asking because the conversion of events to the qapi is not too far away, but I think that using QOM will somewhat deprecate the code you have in the glib branch (besides having to wait for 1.2)? I have some vague ideas about what to do here. One thought would be to have a standard notifier mechanism in Object that was advertised as a property type. We could then provide an interface via QMP to [un]subscribe to a notifier property. This seems to be a good match with your previous ideas, implemented in the glib branch. But then subsystems/devices emitting events will have to be converted to QOM first... I won't get to this until the 1.2 time frame though. My goals for 1.1 are to get qbus conversions merged and refactor IRQs/MemoryRegions to use QOM. If time permits, also refactor the PC to better use QOM. If someone wants to tackle events in QOM, I'd be happy to provide some suggestions on where to start. I'd like to hear about it, but I'm not sure when I'll start working on it.