Re: [Qemu-devel] [PATCH v2 7/9] usb-ehci: add ehci-pci device exit function
On Di, 2014-06-03 at 18:54 +0800, arei.gong...@huawei.com wrote: From: Gonglei arei.gong...@huawei.com clean up ehci resource when ehci pci device exit. Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/hcd-ehci-pci.c | 33 + 1 file changed, 33 insertions(+) diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c index 505741a..115d9b5 100644 --- a/hw/usb/hcd-ehci-pci.c +++ b/hw/usb/hcd-ehci-pci.c @@ -84,6 +84,38 @@ static void usb_ehci_pci_init(Object *obj) usb_ehci_init(s, DEVICE(obj)); } +static void usb_ehci_pci_exit(PCIDevice *dev) +{ Too much non-pci stuff in here. I think we should create a usb_ehci_unrealize function and do the cleanup there, then just call this from usb_ehci_pci_exit. You also don't need patch #6 then. cheers, Gerd
Re: [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug
Hi, changes since v1: * add more completely resource cleanup for every usb host adapter. Looks good overall. How did you test this? cheers, Gerd
Re: [Qemu-devel] [PATCH v2 7/9] usb-ehci: add ehci-pci device exit function
-Original Message- From: Gerd Hoffmann [mailto:kra...@redhat.com] Sent: Wednesday, June 04, 2014 2:10 PM To: Gonglei (Arei) Cc: qemu-devel@nongnu.org; Luonengjun; Huangweidong (C); Huangpeng (Peter) Subject: Re: [PATCH v2 7/9] usb-ehci: add ehci-pci device exit function On Di, 2014-06-03 at 18:54 +0800, arei.gong...@huawei.com wrote: From: Gonglei arei.gong...@huawei.com clean up ehci resource when ehci pci device exit. Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/hcd-ehci-pci.c | 33 + 1 file changed, 33 insertions(+) diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c index 505741a..115d9b5 100644 --- a/hw/usb/hcd-ehci-pci.c +++ b/hw/usb/hcd-ehci-pci.c @@ -84,6 +84,38 @@ static void usb_ehci_pci_init(Object *obj) usb_ehci_init(s, DEVICE(obj)); } +static void usb_ehci_pci_exit(PCIDevice *dev) +{ Too much non-pci stuff in here. I think we should create a usb_ehci_unrealize function and do the cleanup there, then just call this from usb_ehci_pci_exit. You also don't need patch #6 then. Good idea! I will do it in v3, Thanks! Best regards, -Gonglei
Re: [Qemu-devel] [PATCH v2 1/2] sheepdog: fix vdi object update after live snapshot
On Tue, Jun 03, 2014 at 11:58:21PM +0900, Hitoshi Mitake wrote: On Tue, Jun 3, 2014 at 9:41 PM, Liu Yuan namei.u...@gmail.com wrote: On Tue, Jun 03, 2014 at 01:54:21PM +0900, Hitoshi Mitake wrote: sheepdog driver should decide a write request is COW or not based on inode object which is active when the write request is issued. Cc: Kevin Wolf kw...@redhat.com Cc: Stefan Hajnoczi stefa...@redhat.com Cc: Liu Yuan namei.u...@gmail.com Cc: MORITA Kazutaka morita.kazut...@lab.ntt.co.jp Signed-off-by: Hitoshi Mitake mitake.hito...@lab.ntt.co.jp --- block/sheepdog.c | 40 +++- 1 files changed, 23 insertions(+), 17 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 4ecbf5f..637e57f 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -282,6 +282,7 @@ typedef struct AIOReq { unsigned int data_len; uint8_t flags; uint32_t id; +bool create; QLIST_ENTRY(AIOReq) aio_siblings; } AIOReq; @@ -404,7 +405,7 @@ static const char * sd_strerror(int err) static inline AIOReq *alloc_aio_req(BDRVSheepdogState *s, SheepdogAIOCB *acb, uint64_t oid, unsigned int data_len, -uint64_t offset, uint8_t flags, +uint64_t offset, uint8_t flags, bool create, uint64_t base_oid, unsigned int iov_offset) { AIOReq *aio_req; @@ -418,6 +419,7 @@ static inline AIOReq *alloc_aio_req(BDRVSheepdogState *s, SheepdogAIOCB *acb, aio_req-data_len = data_len; aio_req-flags = flags; aio_req-id = s-aioreq_seq_num++; +aio_req-create = create; acb-nr_pending++; return aio_req; @@ -664,8 +666,8 @@ static int do_req(int sockfd, SheepdogReq *hdr, void *data, } static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, - struct iovec *iov, int niov, bool create, - enum AIOCBState aiocb_type); + struct iovec *iov, int niov, + enum AIOCBState aiocb_type); static void coroutine_fn resend_aioreq(BDRVSheepdogState *s, AIOReq *aio_req); static int reload_inode(BDRVSheepdogState *s, uint32_t snapid, const char *tag); static int get_sheep_fd(BDRVSheepdogState *s, Error **errp); @@ -698,7 +700,7 @@ static void coroutine_fn send_pending_req(BDRVSheepdogState *s, uint64_t oid) /* move aio_req from pending list to inflight one */ QLIST_REMOVE(aio_req, aio_siblings); QLIST_INSERT_HEAD(s-inflight_aio_head, aio_req, aio_siblings); -add_aio_request(s, aio_req, acb-qiov-iov, acb-qiov-niov, false, +add_aio_request(s, aio_req, acb-qiov-iov, acb-qiov-niov, acb-aiocb_type); } } @@ -797,7 +799,7 @@ static void coroutine_fn aio_read_response(void *opaque) } idx = data_oid_to_idx(aio_req-oid); -if (s-inode.data_vdi_id[idx] != s-inode.vdi_id) { +if (aio_req-create) { /* * If the object is newly created one, we need to update * the vdi object (metadata object). min_dirty_data_idx @@ -1117,8 +1119,8 @@ out: } static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, - struct iovec *iov, int niov, bool create, - enum AIOCBState aiocb_type) + struct iovec *iov, int niov, + enum AIOCBState aiocb_type) { int nr_copies = s-inode.nr_copies; SheepdogObjReq hdr; @@ -1129,6 +1131,7 @@ static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, uint64_t offset = aio_req-offset; uint8_t flags = aio_req-flags; uint64_t old_oid = aio_req-base_oid; +bool create = aio_req-create; if (!nr_copies) { error_report(bug); @@ -1315,6 +1318,7 @@ static bool check_simultaneous_create(BDRVSheepdogState *s, AIOReq *aio_req) DPRINTF(simultaneous create to % PRIx64 \n, aio_req-oid); aio_req-flags = 0; aio_req-base_oid = 0; +aio_req-create = false; QLIST_REMOVE(aio_req, aio_siblings); QLIST_INSERT_HEAD(s-pending_aio_head, aio_req, aio_siblings); return true; @@ -1327,7 +1331,8 @@ static bool check_simultaneous_create(BDRVSheepdogState *s, AIOReq *aio_req) static void coroutine_fn resend_aioreq(BDRVSheepdogState *s, AIOReq *aio_req) { SheepdogAIOCB *acb = aio_req-aiocb; -bool create = false; + +aio_req-create = false; /* check whether this request becomes a CoW one */
[Qemu-devel] [PATCH v2 0/8] Obtain dirty bitmap via VM logging
Hi, The following patches introduce the support of dirty bitmap logging and dumping to a specified file. Still, some work is still left in the area of runstates that I will try to work on after discussing this patch series. v1 -- v2: * Added two new run states to avoid simultaneous execution of both migration and bitmap dump process. * Removed FILE pointer usage. * Dumping the data only in machine-readable format. * Tried to rectify mistakes of the previous version. Sanidhya Kashyap (8): enable sharing of the function between migration and bitmap dump bitmap dump code via QAPI framework RunState: added two new flags for bitmap dump and migration process bitmap dump process with runstates hmp interface for dirty bitmap dump cancel mechanism for an already running dump bitmap process set the frequency of the dump bitmap process python script for extracting bitmap from a binary file arch_init.c | 19 +-- hmp-commands.hx | 45 +++ hmp.c | 33 ++ hmp.h | 3 + include/exec/ram_addr.h | 4 + migration.c | 7 ++ qapi-schema.json | 42 ++- qmp-commands.hx | 76 savevm.c | 290 ++ scripts/extract-bitmap.py | 64 ++ vl.c | 29 - 11 files changed, 602 insertions(+), 10 deletions(-) create mode 100755 scripts/extract-bitmap.py -- 1.8.3.1
[Qemu-devel] [PATCH v2 2/8] bitmap dump code via QAPI framework
Following are the changes made with respect to the previous version: Chen's advice 1) Replaced DIRTY_MEMORY_LOG_BITMAP with DIRTY_MEMORY_MIGRATION and completely removed the DIRTY_MEMORY_LOG_BITMAP flag. Eric's advice 2) Replaced FILE pointer with file descriptor. 3) Replaced fopen/fclose with qemu_open / qemu_close. 4) Removed text format, output only in machine-readable format. 5) Defined constants. Signed-off-by: Sanidhya Kashyap sanidhya.ii...@gmail.com --- qapi-schema.json | 17 qmp-commands.hx | 33 savevm.c | 246 +++ 3 files changed, 296 insertions(+) diff --git a/qapi-schema.json b/qapi-schema.json index 7bc33ea..17e5147 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4722,3 +4722,20 @@ 'btn' : 'InputBtnEvent', 'rel' : 'InputMoveEvent', 'abs' : 'InputMoveEvent' } } +## +# @log-dirty-bitmap +# +# dumps the dirty bitmap to a file by logging the +# memory for a specified number of times with a +# a defined time differnce +# +# @filename: name of the file in which the bitmap will be saved. +# @epochs: number of times the memory will be logged. +# @frequency: time difference in milliseconds between each epoch. +# +# Since 2.1 +## +{ 'command' : 'log-dirty-bitmap', + 'data': { 'filename' : 'str', +'*epochs' : 'int', +'*frequency': 'int' } } diff --git a/qmp-commands.hx b/qmp-commands.hx index d8aa4ed..183a636 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3572,3 +3572,36 @@ Example: } } ] } EQMP + +{ +.name = log-dirty-bitmap, +.args_type = filename:s,epochs:i?,frequency:i?,readable:-r?, +.mhandler.cmd_new = qmp_marshal_input_log_dirty_bitmap, +}, + +SQMP +log-dirty-bitmap + + +start logging the memory of the VM for writable working set + +Arguments: + +- filename: name of the file, in which the bitmap will be saved +- epochs: number of times, the memory will be logged +- frequency: time difference in milliseconds between each epoch + +Examples: +- { execute : log-dirty-bitmap, + arguments : { + filename : /tmp/fileXXX, + epochs : 3, + frequency : 10 } } + +- { return: {} } + +Note: The epochs, frequency and readable are optional. epochs default +value is 3 while that of frequency is 10. + +EQMP + diff --git a/savevm.c b/savevm.c index da8aa24..525b388 100644 --- a/savevm.c +++ b/savevm.c @@ -41,6 +41,9 @@ #include qemu/iov.h #include block/snapshot.h #include block/qapi.h +#include exec/address-spaces.h +#include exec/ram_addr.h +#include qemu/bitmap.h #define SELF_ANNOUNCE_ROUNDS 5 @@ -1002,6 +1005,249 @@ void do_savevm(Monitor *mon, const QDict *qdict) } } +/* + * Adding the functionality of continuous logging of the + * dirty bitmap which is almost similar to the migration + * thread + */ + +enum { +LOG_BITMAP_STATE_ERROR = -1, +LOG_BITMAP_STATE_NONE, +LOG_BITMAP_STATE_SETUP, +LOG_BITMAP_STATE_ACTIVE, +LOG_BITMAP_STATE_CANCELING, +LOG_BITMAP_STATE_COMPLETED +}; + +typedef struct BitmapLogState BitmapLogState; +static unsigned long *logging_bitmap; +static int64_t MIN_EPOCH_VALUE = 3; +static int64_t MIN_FREQUENCY_VALUE = 10; +static int64_t LOG_SIZE_MAX = 10; + +struct BitmapLogState { +int state; +int fd; +int64_t current_frequency; +int64_t total_epochs; +QemuThread thread; +}; + +/* + * helper functions + */ + +static inline void logging_lock(void) +{ +qemu_mutex_lock_iothread(); +qemu_mutex_lock_ramlist(); +} + +static inline void logging_unlock(void) +{ +qemu_mutex_unlock_ramlist(); +qemu_mutex_unlock_iothread(); +} + +static inline void logging_bitmap_set_dirty(ram_addr_t addr) +{ +int nr = addr TARGET_PAGE_BITS; +set_bit(nr, logging_bitmap); +} + +static bool logging_state_set_status(BitmapLogState *b, + int old_state, + int new_state) +{ +return atomic_cmpxchg(b-state, old_state, new_state); +} + +static inline bool check_value(int64_t value, int64_t min_value, + const char *str, Error **errp) +{ +if (value min_value) { +error_setg(errp, %s's value must be greater than %ld, + str, min_value); +return false; +} +if (value LOG_SIZE_MAX) { +error_setg(errp, %s's value must be less than %ld, + str, LOG_SIZE_MAX); +return false; +} +return true; +} + +/* + * inspired from migration mechanism + */ + +static BitmapLogState *logging_current_state(void) +{ +static BitmapLogState current_bitmaplogstate = { +.state = LOG_BITMAP_STATE_NONE, +}; + +return current_bitmaplogstate; +} + +/* + * syncing the logging_bitmap with the ram_list dirty bitmap + */ + +static void
[Qemu-devel] [PATCH v2 8/8] python script for extracting bitmap from a binary file
No particular functional change. This file does not need to be included in the Makefile as it will be only useful once the user has generated the bitmap file via bitmap dump process. Signed-off-by: Sanidhya Kashyap sanidhya.ii...@gmail.com --- scripts/extract-bitmap.py | 64 +++ 1 file changed, 64 insertions(+) create mode 100755 scripts/extract-bitmap.py diff --git a/scripts/extract-bitmap.py b/scripts/extract-bitmap.py new file mode 100755 index 000..f5ca341 --- /dev/null +++ b/scripts/extract-bitmap.py @@ -0,0 +1,64 @@ +#!/usr/bin/python +# This python script helps in extracting the dirty bitmap present +# in the file after executing the log-dirty-bitmap command either +# from the qmp or hmp interface. This file only processes binary +# file obtained via command. +# +# Copyright (C) 2014 Sanidhya Kashyap sanidhya.ii...@gmail.com +# +# Authors: +# Sanidhya Kashyap +# +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. + +import struct +import argparse +from functools import partial + +long_bytes = 8 +complete_bitmap_list = [] + +def get_unsigned_long_integer(value): +return struct.unpack('Q', value)[0] + +def get_long_integer(value): +return struct.unpack('q',value)[0] + +def dump_bitmap(infile, bitmap_length): +count = 1 +bitmap_list = [] +for value in iter(partial(infile.read, long_bytes), ''): +if (count % bitmap_length): +count += 1 +bitmap_list.append(hex(get_unsigned_long_integer(value))) +else: +complete_bitmap_list.append(bitmap_list) +count = 1 +bitmap_list = [] +# currently, the complete list is printed. It is up to the user to decide about +# the usage of the bitmap as the bitmap provides the writable working set of the +# VM for a particular duration. +print complete_bitmap_list + +def main(): +extracter = argparse.ArgumentParser(description='Extract dirty bitmap from binary file.') +extracter.add_argument('infile', help='Input file to extract the bitmap') +args = extracter.parse_args() +print 'The filename is {}'.format(args.infile) + +infile = open(format(args.infile), 'rb') + +ram_bitmap_pages = get_long_integer(infile.read(long_bytes)) +print ram_bitmap_pages +bitmap_length = ram_bitmap_pages / long_bytes +if ram_bitmap_pages % long_bytes != 0: +bitmap_length += 1 +print bitmap_length + +dump_bitmap(infile, bitmap_length); + +infile.close() + +if __name__ == '__main__': +main() -- 1.8.3.1
[Qemu-devel] [PATCH v2 3/8] RunState: added two new flags for bitmap dump and migration process
I have added two new flags - RUN_STATE_MIGRATE and RUN_STATE_DUMP_BITMAP. These both flags behave same as RUN_STATE_RUNNING flag. The purpose of introducing these flags is to avoid running both migration and dump bitmap process simultaneously. I haven't added many transitions to the RUN_STATE_DUMP_BITMAP. I will try to include the transitions on the basis of discussions. On the other hand, I have tried to add the transitions that might occur during the migration process. There is a possibility that some transitions can be redundant (as pointed by Chen, this is not my patch problem, but I have tried to cover what I thought is necessary). Signed-off-by: Sanidhya Kashyap sanidhya.ii...@gmail.com --- qapi-schema.json | 7 ++- vl.c | 29 - 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 17e5147..2918fc4 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -234,12 +234,17 @@ # @watchdog: the watchdog action is configured to pause and has been triggered # # @guest-panicked: guest has been panicked as a result of guest OS panic +# +# @migrate: migration process is being executed +# +# @dump-bitmap: dump the writable working set of the guest +# ## { 'enum': 'RunState', 'data': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paused', 'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm', 'running', 'save-vm', 'shutdown', 'suspended', 'watchdog', -'guest-panicked' ] } +'guest-panicked', 'migrate', 'dump-bitmap' ] } ## # @SnapshotInfo diff --git a/vl.c b/vl.c index 709d8cd..a2ffd66 100644 --- a/vl.c +++ b/vl.c @@ -576,31 +576,39 @@ static const RunStateTransition runstate_transitions_def[] = { /* from - to */ { RUN_STATE_DEBUG, RUN_STATE_RUNNING }, { RUN_STATE_DEBUG, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_DEBUG, RUN_STATE_MIGRATE }, { RUN_STATE_INMIGRATE, RUN_STATE_RUNNING }, { RUN_STATE_INMIGRATE, RUN_STATE_PAUSED }, { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED }, { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_INTERNAL_ERROR, RUN_STATE_MIGRATE }, { RUN_STATE_IO_ERROR, RUN_STATE_RUNNING }, { RUN_STATE_IO_ERROR, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_IO_ERROR, RUN_STATE_MIGRATE }, { RUN_STATE_PAUSED, RUN_STATE_RUNNING }, { RUN_STATE_PAUSED, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_PAUSED, RUN_STATE_MIGRATE }, { RUN_STATE_POSTMIGRATE, RUN_STATE_RUNNING }, { RUN_STATE_POSTMIGRATE, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_POSTMIGRATE, RUN_STATE_MIGRATE }, { RUN_STATE_PRELAUNCH, RUN_STATE_RUNNING }, { RUN_STATE_PRELAUNCH, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, +{ RUN_STATE_PRELAUNCH, RUN_STATE_MIGRATE }, { RUN_STATE_FINISH_MIGRATE, RUN_STATE_RUNNING }, { RUN_STATE_FINISH_MIGRATE, RUN_STATE_POSTMIGRATE }, { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING }, +{ RUN_STATE_DUMP_BITMAP, RUN_STATE_RUNNING}, + { RUN_STATE_RUNNING, RUN_STATE_DEBUG }, { RUN_STATE_RUNNING, RUN_STATE_INTERNAL_ERROR }, { RUN_STATE_RUNNING, RUN_STATE_IO_ERROR }, @@ -611,6 +619,8 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_RUNNING, RUN_STATE_SHUTDOWN }, { RUN_STATE_RUNNING, RUN_STATE_WATCHDOG }, { RUN_STATE_RUNNING, RUN_STATE_GUEST_PANICKED }, +{ RUN_STATE_RUNNING, RUN_STATE_DUMP_BITMAP }, +{ RUN_STATE_RUNNING, RUN_STATE_MIGRATE }, { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING }, @@ -621,12 +631,27 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_RUNNING, RUN_STATE_SUSPENDED }, { RUN_STATE_SUSPENDED, RUN_STATE_RUNNING }, { RUN_STATE_SUSPENDED, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_SUSPENDED, RUN_STATE_MIGRATE }, { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING }, { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_WATCHDOG, RUN_STATE_MIGRATE }, { RUN_STATE_GUEST_PANICKED, RUN_STATE_RUNNING }, { RUN_STATE_GUEST_PANICKED, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_GUEST_PANICKED, RUN_STATE_MIGRATE }, + +{ RUN_STATE_DUMP_BITMAP, RUN_STATE_RUNNING }, + +{ RUN_STATE_MIGRATE, RUN_STATE_POSTMIGRATE }, +{ RUN_STATE_MIGRATE, RUN_STATE_PAUSED }, +{ RUN_STATE_MIGRATE, RUN_STATE_SHUTDOWN }, +{ RUN_STATE_MIGRATE, RUN_STATE_GUEST_PANICKED }, +{ RUN_STATE_MIGRATE, RUN_STATE_DEBUG }, +{ RUN_STATE_MIGRATE, RUN_STATE_RUNNING }, +{ RUN_STATE_MIGRATE, RUN_STATE_INTERNAL_ERROR }, +{ RUN_STATE_MIGRATE, RUN_STATE_IO_ERROR }, +{ RUN_STATE_MIGRATE, RUN_STATE_WATCHDOG }, { RUN_STATE_MAX, RUN_STATE_MAX }, }; @@ -666,7 +691,9 @@ void runstate_set(RunState new_state) int runstate_is_running(void) { -return runstate_check(RUN_STATE_RUNNING); +return
Re: [Qemu-devel] [PATCH v2 0/9] usb: usb host adapter hotplug
-Original Message- From: Gerd Hoffmann [mailto:kra...@redhat.com] Sent: Wednesday, June 04, 2014 2:12 PM To: Gonglei (Arei) Cc: qemu-devel@nongnu.org; Luonengjun; Huangweidong (C); Huangpeng (Peter) Subject: Re: [PATCH v2 0/9] usb: usb host adapter hotplug Hi, changes since v1: * add more completely resource cleanup for every usb host adapter. Looks good overall. How did you test this? Thanks! The steps of tested: 1. start a vm using below qemu command line: ./qemu-system-x86_64 -enable-kvm -m 4096 -smp 4 -name win7 -boot c -drive file=/mnt/sdb/gonglei/image/win7_32_2U -vnc 0.0.0.0:10 -monitor stdio 2. hot-plug/unplug an usb host adapters: 2.1) For ehci: (qemu) device_add usb-ehci,id=ehci (qemu) device_add usb-tablet,id=input0,bus=ehci.0,port=1 (qemu) device_del ehci 2.2) For uhci: (qemu) device_add piix3-usb-uhci,id=uhci (qemu) device_del uhci 2.3) For uhci: (qemu) device_add pci-ohci,id=ohci (qemu) device_del ohci 2.4) For uhci: (qemu) device_add nec-usb-xhci,id=xhci (qemu) device_del xhci 3. do step #2 repeating, more than 20 times. BTW, I will add some qtestes for usb host adapters hot-plug/unplug later, and add tracing for exit function. Best regards, -Gonglei
[Qemu-devel] [PATCH v2 4/8] bitmap dump process with runstates
Introduced both runstates: RUN_STATE_MIGRATE and RUN_STATE_DUMP_BITMAP to both migration and bitmap dump process. I want the bitmap dump process to get canceled so whenever the state changes from RUN_STATE_BITMAP to something else. But, this does not happen when I stop the guest via stop qmp interface as the current_run_state variable is not updated. Any thoughts on that? Do I need to make the changes there as well or is there any simple way to do it? Signed-off-by: Sanidhya Kashyap sanidhya.ii...@gmail.com --- migration.c | 7 +++ savevm.c| 26 +++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/migration.c b/migration.c index 3fc03d6..d91dd4c 100644 --- a/migration.c +++ b/migration.c @@ -436,6 +436,13 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, return; } +if (runstate_check(RUN_STATE_DUMP_BITMAP)) { +error_setg(errp, bitmap dump in progress); +return; +} + +runstate_set(RUN_STATE_MIGRATE); + s = migrate_init(params); if (strstart(uri, tcp:, p)) { diff --git a/savevm.c b/savevm.c index 525b388..675c8e5 100644 --- a/savevm.c +++ b/savevm.c @@ -1163,7 +1163,8 @@ static void *bitmap_logging_thread(void *opaque) * using the FILE pointer f. */ while (epoch_count total_epochs) { -if (!runstate_is_running() || b-state != LOG_BITMAP_STATE_ACTIVE) { +if (!runstate_check(RUN_STATE_DUMP_BITMAP) || +b-state != LOG_BITMAP_STATE_ACTIVE) { goto log_thread_end; } bitmap_zero(logging_bitmap, ram_bitmap_pages); @@ -1193,6 +1194,7 @@ static void *bitmap_logging_thread(void *opaque) logging_state_set_status(b, LOG_BITMAP_STATE_ERROR, LOG_BITMAP_STATE_COMPLETED); } +runstate_set(RUN_STATE_RUNNING); return NULL; } @@ -1203,18 +1205,26 @@ void qmp_log_dirty_bitmap(const char *filename, bool has_epochs, int fd = -1; BitmapLogState *b = logging_current_state(); Error *local_err = NULL; -if (b-state == LOG_BITMAP_STATE_ACTIVE || -b-state == LOG_BITMAP_STATE_SETUP || -b-state == LOG_BITMAP_STATE_CANCELING) { + +if (runstate_check(RUN_STATE_DUMP_BITMAP) || +b-state == LOG_BITMAP_STATE_ACTIVE || +b-state == LOG_BITMAP_STATE_SETUP || +b-state == LOG_BITMAP_STATE_CANCELING) { b = NULL; error_setg(errp, dirty bitmap dump in progress); return; } -if (b-state == LOG_BITMAP_STATE_COMPLETED) { -b-state = LOG_BITMAP_STATE_NONE; +if (!runstate_is_running()) { +b = NULL; +error_setg(errp, Guest is not in a running state); +return; } +runstate_set(RUN_STATE_DUMP_BITMAP); + +b-state = LOG_BITMAP_STATE_NONE; + if (!has_epochs) { epochs = MIN_EPOCH_VALUE; } @@ -1227,14 +1237,16 @@ void qmp_log_dirty_bitmap(const char *filename, bool has_epochs, if (local_err) { b = NULL; error_propagate(errp, local_err); +runstate_set(RUN_STATE_RUNNING); return; } } fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR); if (fd 0) { -error_setg_file_open(errp, errno, filename); b = NULL; +error_setg_file_open(errp, errno, filename); +runstate_set(RUN_STATE_RUNNING); return; } -- 1.8.3.1
[Qemu-devel] [PATCH v2 7/8] set the frequency of the dump bitmap process
No particular functional change. Corrected some mistakes. Signed-off-by: Sanidhya Kashyap sanidhya.ii...@gmail.com --- hmp-commands.hx | 15 +++ hmp.c| 12 hmp.h| 1 + qapi-schema.json | 10 ++ qmp-commands.hx | 23 +++ savevm.c | 13 + 6 files changed, 74 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 501e011..ce0d9b5 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1810,6 +1810,21 @@ STEXI Cancel the current bitmap dump process ETEXI +{ +.name = ldbsf|log-dirty-bitmap-set-frequency, +.args_type = frequency:i, +.params = frequency, +.help = set the frequency for bitmap dump process\n\t\t\t + frequency: the new frequency value to replace the existing, +.mhandler.cmd = hmp_log_dirty_bitmap_set_frequency, +}, + +STEXI +@item ldbsf or log-dirty-bitmap-set-frequency @var{frequency} +@findex log-dirty-bitmap-set-frequency +Set the frequency to @var{frequency} (int) for bitmap dump process. +ETEXI + STEXI @end table ETEXI diff --git a/hmp.c b/hmp.c index fed8795..8765093 100644 --- a/hmp.c +++ b/hmp.c @@ -1335,6 +1335,18 @@ void hmp_log_dirty_bitmap_cancel(Monitor *mon, const QDict *qdict) qmp_log_dirty_bitmap_cancel(NULL); } +void hmp_log_dirty_bitmap_set_frequency(Monitor *mon, const QDict *qdict) +{ +int64_t frequency = qdict_get_int(qdict, frequency); +Error *err = NULL; +qmp_log_dirty_bitmap_set_frequency(frequency, err); +if (err) { +monitor_printf(mon, log-dirty-bitmap-set-frequency: %s\n, + error_get_pretty(err)); +error_free(err); +} +} + void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) { Error *err = NULL; diff --git a/hmp.h b/hmp.h index b600429..991be02 100644 --- a/hmp.h +++ b/hmp.h @@ -95,6 +95,7 @@ void hmp_object_add(Monitor *mon, const QDict *qdict); void hmp_object_del(Monitor *mon, const QDict *qdict); void hmp_log_dirty_bitmap(Monitor *mon, const QDict *qdict); void hmp_log_dirty_bitmap_cancel(Monitor *mon, const QDict *qdict); +void hmp_log_dirty_bitmap_set_frequency(Monitor *mon, const QDict *qdict); void object_add_completion(ReadLineState *rs, int nb_args, const char *str); void object_del_completion(ReadLineState *rs, int nb_args, const char *str); void device_add_completion(ReadLineState *rs, int nb_args, const char *str); diff --git a/qapi-schema.json b/qapi-schema.json index 9f9f097..7b7e4de 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4752,3 +4752,13 @@ # Since 2.1 ## { 'command': 'log-dirty-bitmap-cancel' } + +## @log-dirty-bitmap-set-frequency +# +# sets the frequency of the dirty bitmap logging process +# @frequency: the updated frequency value +# +# Since 2.1 +## +{ 'command': 'log-dirty-bitmap-set-frequency', + 'data': {'frequency': 'int' } } diff --git a/qmp-commands.hx b/qmp-commands.hx index 2a8dacc..51a0ad8 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3625,3 +3625,26 @@ Example: - { return: {} } EQMP + +{ +.name = log-dirty-bitmap-set-frequency, +.args_type = frequency:i, +.mhandler.cmd_new = qmp_marshal_input_log_dirty_bitmap_set_frequency, +}, + +SQMP +log-dirty-bitmap-set-frequency + + +Update the frequency for the remaining epochs. + +Arguments: + +- frequency: the updated frequency (json-int) + +Example: + +- { execute: log-dirty-bitmap-set-frequency, arguments: { value: 1024 } } +- { return: {} } + +EQMP diff --git a/savevm.c b/savevm.c index ff87254..cfa8dce 100644 --- a/savevm.c +++ b/savevm.c @@ -1279,6 +1279,19 @@ void qmp_log_dirty_bitmap_cancel(Error **errp) logging_bitmap_cancel(logging_current_state()); } +void qmp_log_dirty_bitmap_set_frequency(int64_t frequency, Error **errp) +{ +BitmapLogState *b = logging_current_state(); +Error *local_err = NULL; +if (!check_value(frequency, MIN_FREQUENCY_VALUE, frequency, local_err)) { +if (local_err) { +error_propagate(errp, local_err); +return; +} +} +b-current_frequency = frequency; +} + void qmp_xen_save_devices_state(const char *filename, Error **errp) { QEMUFile *f; -- 1.8.3.1
[Qemu-devel] [PATCH v2 1/8] enable sharing of the function between migration and bitmap dump
As advised by Eric, I have enabled sharing of the function between of the function that syncs the dirty bitmap obtained via kvm ioctl. I have tried to make the least changes to the functions by concentrating only on the function definitions. Signed-off-by: Sanidhya Kashyap sanidhya.ii...@gmail.com --- arch_init.c | 19 +++ include/exec/ram_addr.h | 4 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/arch_init.c b/arch_init.c index 685ba0e..48eb90a 100644 --- a/arch_init.c +++ b/arch_init.c @@ -434,20 +434,22 @@ ram_addr_t migration_bitmap_find_and_reset_dirty(MemoryRegion *mr, return (next - base) TARGET_PAGE_BITS; } -static inline bool migration_bitmap_set_dirty(ram_addr_t addr) +static inline bool bitmap_set_dirty(ram_addr_t addr, unsigned long *bitmap, + bool migration_flag) { bool ret; int nr = addr TARGET_PAGE_BITS; -ret = test_and_set_bit(nr, migration_bitmap); +ret = test_and_set_bit(nr, bitmap); -if (!ret) { +if (!ret migration_flag) { migration_dirty_pages++; } return ret; } -static void migration_bitmap_sync_range(ram_addr_t start, ram_addr_t length) +void bitmap_sync_range(ram_addr_t start, ram_addr_t length, + unsigned long *bitmap, bool migration_flag) { ram_addr_t addr; unsigned long page = BIT_WORD(start TARGET_PAGE_BITS); @@ -461,8 +463,8 @@ static void migration_bitmap_sync_range(ram_addr_t start, ram_addr_t length) for (k = page; k page + nr; k++) { if (src[k]) { unsigned long new_dirty; -new_dirty = ~migration_bitmap[k]; -migration_bitmap[k] |= src[k]; +new_dirty = ~bitmap[k]; +bitmap[k] |= src[k]; new_dirty = src[k]; migration_dirty_pages += ctpopl(new_dirty); src[k] = 0; @@ -476,7 +478,7 @@ static void migration_bitmap_sync_range(ram_addr_t start, ram_addr_t length) cpu_physical_memory_reset_dirty(start + addr, TARGET_PAGE_SIZE, DIRTY_MEMORY_MIGRATION); -migration_bitmap_set_dirty(start + addr); +bitmap_set_dirty(start + addr, bitmap, migration_flag); } } } @@ -512,7 +514,8 @@ static void migration_bitmap_sync(void) address_space_sync_dirty_bitmap(address_space_memory); QTAILQ_FOREACH(block, ram_list.blocks, next) { -migration_bitmap_sync_range(block-mr-ram_addr, block-length); +bitmap_sync_range(block-mr-ram_addr, block-length, + migration_bitmap, true); } trace_migration_bitmap_sync_end(migration_dirty_pages - num_dirty_pages_init); diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 2edfa96..ca7d248 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -146,5 +146,9 @@ static inline void cpu_physical_memory_clear_dirty_range(ram_addr_t start, void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t length, unsigned client); + +void bitmap_sync_range(ram_addr_t start, ram_addr_t length, + unsigned long *bitmap, bool migration_flag); + #endif #endif -- 1.8.3.1
Re: [Qemu-devel] [PATCH v1 07/16] target-arm: Add HCR_EL2
On Tue, Jun 03, 2014 at 11:27:55AM +0100, Alex Bennée wrote: Edgar E. Iglesias writes: From: Edgar E. Iglesias edgar.igles...@xilinx.com Signed-off-by: Edgar E. Iglesias edgar.igles...@xilinx.com --- target-arm/cpu.h| 35 +++ target-arm/helper.c | 27 +++ 2 files changed, 62 insertions(+) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index ef6a95d..b446478 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -184,6 +184,7 @@ typedef struct CPUARMState { MPU write buffer control. */ uint32_t pmsav5_data_ap; /* PMSAv5 MPU data access permissions */ uint32_t pmsav5_insn_ap; /* PMSAv5 MPU insn access permissions */ +uint64_t hcr_el2; /* Hypervisor configuration register */ uint32_t ifsr_el2; /* Fault status registers. */ uint64_t esr_el[4]; uint32_t c6_region[8]; /* MPU base/size registers. */ @@ -526,6 +527,40 @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) } } +#define HCR_VM(1ULL 0) +#define HCR_SWIO (1ULL 1) +#define HCR_PTW (1ULL 2) +#define HCR_FMO (1ULL 3) +#define HCR_IMO (1ULL 4) +#define HCR_AMO (1ULL 5) +#define HCR_VF(1ULL 6) +#define HCR_VI(1ULL 7) +#define HCR_VSE (1ULL 8) +#define HCR_FB(1ULL 9) +#define HCR_DC(1ULL 12) +#define HCR_TWI (1ULL 13) +#define HCR_TWE (1ULL 14) +#define HCR_TID0 (1ULL 15) +#define HCR_TID1 (1ULL 16) +#define HCR_TID2 (1ULL 17) +#define HCR_TID3 (1ULL 18) +#define HCR_TSC (1ULL 19) +#define HCR_TIDCP (1ULL 20) +#define HCR_TACR (1ULL 21) +#define HCR_TSW (1ULL 22) +#define HCR_TPC (1ULL 23) +#define HCR_TPU (1ULL 24) +#define HCR_TTLB (1ULL 25) +#define HCR_TVM (1ULL 26) +#define HCR_TGE (1ULL 27) +#define HCR_TDZ (1ULL 28) +#define HCR_HCD (1ULL 29) +#define HCR_TRVM (1ULL 30) +#define HCR_RW(1ULL 31) +#define HCR_CD(1ULL 32) +#define HCR_ID(1ULL 33) +#define HCR_RES0_MASK ((1ULL 34) - 1) Hmm isn't that actually HCR_MASK? I would expect the mask for the RES0 bits to be ~((1ULL 34) - 1) but it's not actually used for that hence the name confusion. I can change the name for v2, thanks. + /* Return the current FPSCR value. */ uint32_t vfp_get_fpscr(CPUARMState *env); void vfp_set_fpscr(CPUARMState *env, uint32_t val); diff --git a/target-arm/helper.c b/target-arm/helper.c index de5ee40..cf877ae 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -2107,10 +2107,37 @@ static const ARMCPRegInfo v8_el3_no_el2_cp_reginfo[] = { .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 0, .access = PL2_RW, .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore }, +{ .name = HCR_EL2, .state = ARM_CP_STATE_AA64, + .type = ARM_CP_NO_MIGRATE, + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, + .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore }, REGINFO_SENTINEL }; +static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) +{ +ARMCPU *cpu = arm_env_get_cpu(env); +uint64_t res0_mask = HCR_RES0_MASK; + +if (!arm_feature(env, ARM_FEATURE_EL3)) { +res0_mask = ~HCR_HCD; +} + +/* Clear RES0 bits. */ +value = res0_mask; + +if ((raw_read(env, ri) ^ value) HCR_VM) { +/* Flush the TLB when turning VM on/off. */ +tlb_flush(CPU(cpu), 1); +} +raw_write(env, ri, value); +} + static const ARMCPRegInfo v8_el2_cp_reginfo[] = { +{ .name = HCR_EL2, .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, + .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2), + .writefn = hcr_write }, { .name = ELR_EL2, .state = ARM_CP_STATE_AA64, .type = ARM_CP_NO_MIGRATE, .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 0, .opc2 = 1, -- Alex Bennée
Re: [Qemu-devel] [PATCH v1 10/16] target-arm: Break out exception masking to a separate func
On Tue, Jun 03, 2014 at 11:32:59AM +0100, Alex Bennée wrote: Edgar E. Iglesias writes: From: Edgar E. Iglesias edgar.igles...@xilinx.com Signed-off-by: Edgar E. Iglesias edgar.igles...@xilinx.com --- cpu-exec.c | 5 ++--- target-arm/cpu.h | 16 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 38e5f02..a579ffc 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -478,7 +478,7 @@ int cpu_exec(CPUArchState *env) } #elif defined(TARGET_ARM) if (interrupt_request CPU_INTERRUPT_FIQ - !(env-daif PSTATE_F)) { + arm_excp_unmasked(cpu, EXCP_FIQ)) { cpu-exception_index = EXCP_FIQ; cc-do_interrupt(cpu); next_tb = 0; @@ -493,8 +493,7 @@ int cpu_exec(CPUArchState *env) We avoid this by disabling interrupts when pc contains a magic address. */ if (interrupt_request CPU_INTERRUPT_HARD - ((IS_M(env) env-regs[15] 0xfff0) -|| !(env-daif PSTATE_I))) { + arm_excp_unmasked(cpu, EXCP_IRQ)) { cpu-exception_index = EXCP_IRQ; cc-do_interrupt(cpu); next_tb = 0; diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 5c74adc..9eddcc1 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -1130,6 +1130,22 @@ bool write_cpustate_to_list(ARMCPU *cpu); # define TARGET_VIRT_ADDR_SPACE_BITS 32 #endif +static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx) +{ +CPUARMState *env = cs-env_ptr; + +switch (excp_idx) { +case EXCP_FIQ: +return !(env-daif PSTATE_F); +case EXCP_IRQ: +return ((IS_M(env) env-regs[15] 0xfff0) +|| !(env-daif PSTATE_I)); +default: +assert(0); g_assert_not_reached() is clearer about the intent here. Sounds good, will change it. Thanks, Edgar +break; +} +} + static inline CPUARMState *cpu_init(const char *cpu_model) { ARMCPU *cpu = cpu_arm_init(cpu_model); -- Alex Bennée
Re: [Qemu-devel] [PATCH v1 13/16] target-arm: A64: Emulate the HVC insn
On Tue, Jun 03, 2014 at 11:41:25AM +0100, Alex Bennée wrote: Edgar E. Iglesias writes: From: Edgar E. Iglesias edgar.igles...@xilinx.com Signed-off-by: Edgar E. Iglesias edgar.igles...@xilinx.com --- target-arm/cpu.h | 7 ++- target-arm/helper-a64.c| 1 + target-arm/helper.c| 39 +++ target-arm/helper.h| 1 + target-arm/internals.h | 6 ++ target-arm/op_helper.c | 21 + target-arm/translate-a64.c | 21 - 7 files changed, 86 insertions(+), 10 deletions(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 66c58bd..1a26ed4 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -51,6 +51,7 @@ #define EXCP_EXCEPTION_EXIT 8 /* Return from v7M exception. */ #define EXCP_KERNEL_TRAP 9 /* Jumped to kernel code page. */ #define EXCP_STREX 10 +#define EXCP_HVC11 /* HyperVisor Call */ #define ARMV7M_EXCP_RESET 1 #define ARMV7M_EXCP_NMI 2 @@ -715,11 +716,7 @@ static inline bool arm_el_is_aa64(CPUARMState *env, int el) } void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf); -static inline unsigned int arm_excp_target_el(CPUState *cs, - unsigned int excp_idx) -{ -return 1; -} +unsigned int arm_excp_target_el(CPUState *cs, unsigned int excp_idx); If the earlier commit had added this in the final place to start with the functional diff would be clearer (although it's easy to eyeball in this case). Right, I can change that for v2. /* Interface between CPU and Interrupt controller. */ void armv7m_nvic_set_pending(void *opaque, int irq); diff --git a/target-arm/helper-a64.c b/target-arm/helper-a64.c index c91005f..974fa66 100644 --- a/target-arm/helper-a64.c +++ b/target-arm/helper-a64.c @@ -475,6 +475,7 @@ void aarch64_cpu_do_interrupt(CPUState *cs) case EXCP_BKPT: case EXCP_UDEF: case EXCP_SWI: +case EXCP_HVC: env-cp15.esr_el[new_el] = env-exception.syndrome; break; case EXCP_IRQ: diff --git a/target-arm/helper.c b/target-arm/helper.c index b760748..5b2070c 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -3208,6 +3208,11 @@ uint32_t HELPER(get_r13_banked)(CPUARMState *env, uint32_t mode) return 0; } +unsigned int arm_excp_target_el(CPUState *cs, unsigned int excp_idx) +{ +return 1; +} + #else /* Map CPU modes onto saved register banks. */ @@ -3263,6 +3268,40 @@ void switch_mode(CPUARMState *env, int mode) env-spsr = env-banked_spsr[i]; } +/* + * Determine the target EL for a given exception type. + */ +unsigned int arm_excp_target_el(CPUState *cs, unsigned int excp_idx) +{ +CPUARMState *env = cs-env_ptr; +unsigned int cur_el = arm_current_pl(env); +unsigned int target_el = 1; +bool route_to_el2 = false; +/* FIXME: Use actual secure state. */ +bool secure = false; Should this be here? I've put it there to make it easier for the TZ patches to identify the places they need to update. + it allows me to code the conditions for the exception routing (wrt S/NS). snip static inline void arm_log_exception(int idx) @@ -204,6 +205,11 @@ static inline uint32_t syn_aa64_svc(uint32_t imm16) return (EC_AA64_SVC ARM_EL_EC_SHIFT) | ARM_EL_IL | (imm16 0x); } +static inline uint32_t syn_aa64_hvc(uint32_t imm16) +{ +return (EC_AA64_HVC ARM_EL_EC_SHIFT) | ARM_EL_IL | (imm16 0x); +} The mask seems superfluous (as it is for arm_log_exception) Sorry, can you clarify what you mean here? Are you refering to the imm16? + static inline uint32_t syn_aa32_svc(uint32_t imm16, bool is_thumb) { return (EC_AA32_SVC ARM_EL_EC_SHIFT) | (imm16 0x) diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index 581dc09..6bf34b0 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -384,6 +384,27 @@ void HELPER(msr_i_pstate)(CPUARMState *env, uint32_t op, uint32_t imm) } } +void HELPER(hvc)(CPUARMState *env, uint32_t syndrome) +{ +bool udef; + +/* We've already checked that EL2 exists at translation time. + * EL3.HCE has priority over EL2.HCD. + */ +if (arm_feature(env, ARM_FEATURE_EL3)) { +udef = !(env-cp15.scr_el3 SCR_HCE); +} else { +udef = env-cp15.hcr_el2 HCR_HCD; +} + +if (udef) { +env-exception.syndrome = syn_uncategorized(); +raise_exception(env, EXCP_UDEF); +} +env-exception.syndrome = syndrome; +raise_exception(env, EXCP_HVC); +} + void HELPER(exception_return)(CPUARMState *env) { int cur_el = arm_current_pl(env); diff --git a/target-arm/translate-a64.c
Re: [Qemu-devel] [PATCH 5/5] virtio-blk: Drop VirtIOBlockReq.read
On Tue, 06/03 15:37, Paolo Bonzini wrote: I guess this is more of an RFC, but still a useful starting point for discussion. Il 03/06/2014 14:52, Fam Zheng ha scritto: diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index e406efa..74f0f32 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -146,7 +146,6 @@ typedef struct VirtIOBlockReq { #ifdef CONFIG_VIRTIO_BLK_DATA_PLANE struct VirtIOBlockDataPlane *s; This is just dev-dataplane, so it's trivial to remove. QEMUIOVector *inhdr;/* iovecs for virtio_blk_inhdr */ This can be unified with the in field; the status is only one byte, so using a full-blown QEMUIOVector is overkill. Stefan, what do you think? For the sake of restarting requests, we also need dataplane to populate the out field for dataplane. We can also take the occasion to change it from struct virtio_blk_outhdr * to struct virtio_blk_outhdr for non-dataplane and use iov_discard_front on the elem (see dataplane's process_request function). Can you do it in v2 of this patch series? With this in place we can look at the missing pieces: - rerror/werror - accounting (trivial) - multiwrite (if desired). Yes, good idea. I will do it! Thanks, Fam
Re: [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000
Il 04/06/2014 03:10, Jidong Xiao ha scritto: diff --git a/qemu-2.0.0/target-i386/kvm.c.orig b/qemu-2.0.0/target-i386/kvm.c index 4389959..b8b282d 100644 --- a/qemu-2.0.0/target-i386/kvm.c.orig +++ b/qemu-2.0.0/target-i386/kvm.c @@ -530,7 +530,7 @@ int kvm_arch_init_vcpu(CPUState *cs) memcpy(signature, KVMKVMKVM\0\0\0, 12); c = cpuid_data.entries[cpuid_i++]; c-function = KVM_CPUID_SIGNATURE | kvm_base; -c-eax = 0; + c-eax = KVM_CPUID_FEATURES; c-ebx = signature[0]; c-ecx = signature[1]; c-edx = signature[2]; This should actually be KVM_CPUID_FEATURES | kvm_base, in case Hyper-V leaves are available too. But it is a good catch! Paolo
Re: [Qemu-devel] [PATCH] util/hbitmap.c: Use ctpopl rather than reimplementing a local equivalent
Il 04/06/2014 01:41, Peter Maydell ha scritto: The function popcountl() in hbitmap.c is effectively a reimplementation of what host-utils.h provides as ctpopl(). Use ctpopl() directly; this fixes a failure to compile on NetBSD (whose strings.h erroneously exposes a system popcountl() which clashes with this one). Signed-off-by: Peter Maydell peter.mayd...@linaro.org Reported-by: Martin Husemann mar...@duskware.de --- We haven't compiled on NetBSD for over a year... util/hbitmap.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/util/hbitmap.c b/util/hbitmap.c index d936831..b3060e6 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -92,11 +92,6 @@ struct HBitmap { unsigned long *levels[HBITMAP_LEVELS]; }; -static inline int popcountl(unsigned long l) -{ -return BITS_PER_LONG == 32 ? ctpop32(l) : ctpop64(l); -} - /* Advance hbi to the next nonzero word and return it. hbi-pos * is updated. Returns zero if we reach the end of the bitmap. */ @@ -200,14 +195,14 @@ static uint64_t hb_count_between(HBitmap *hb, uint64_t start, uint64_t last) if (pos = (end BITS_PER_LEVEL)) { break; } -count += popcountl(cur); +count += ctpopl(cur); } if (pos == (end BITS_PER_LEVEL)) { /* Drop bits representing the END-th and subsequent items. */ int bit = end (BITS_PER_LONG - 1); cur = (1UL bit) - 1; -count += popcountl(cur); +count += ctpopl(cur); } return count; Reviewed-by: Paolo Bonzini pbonz...@redhat.com
[Qemu-devel] [PATCH v2 6/8] cancel mechanism for an already running dump bitmap process
No particular functional changes. Rectified some previous mistakes. Signed-off-by: Sanidhya Kashyap sanidhya.ii...@gmail.com --- hmp-commands.hx | 14 ++ hmp.c| 5 + hmp.h| 1 + qapi-schema.json | 8 qmp-commands.hx | 20 savevm.c | 19 +++ 6 files changed, 67 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 1665587..501e011 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1796,6 +1796,20 @@ STEXI dumps the writable working set of a VM's memory to a file ETEXI + { + .name = ldbc|log-dirty-bitmap-cancel, + .args_type = , + .params = , + .help = cancel the current bitmap dump process, + .mhandler.cmd = hmp_log_dirty_bitmap_cancel, +}, + +STEXI +@item ldbc or log-dirty-bitmap-cancel +@findex log-dirty-bitmap-cancel +Cancel the current bitmap dump process +ETEXI + STEXI @end table ETEXI diff --git a/hmp.c b/hmp.c index a400825..fed8795 100644 --- a/hmp.c +++ b/hmp.c @@ -1330,6 +1330,11 @@ void hmp_log_dirty_bitmap(Monitor *mon, const QDict *qdict) } } +void hmp_log_dirty_bitmap_cancel(Monitor *mon, const QDict *qdict) +{ +qmp_log_dirty_bitmap_cancel(NULL); +} + void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) { Error *err = NULL; diff --git a/hmp.h b/hmp.h index 3a79a93..b600429 100644 --- a/hmp.h +++ b/hmp.h @@ -94,6 +94,7 @@ void hmp_cpu_add(Monitor *mon, const QDict *qdict); void hmp_object_add(Monitor *mon, const QDict *qdict); void hmp_object_del(Monitor *mon, const QDict *qdict); void hmp_log_dirty_bitmap(Monitor *mon, const QDict *qdict); +void hmp_log_dirty_bitmap_cancel(Monitor *mon, const QDict *qdict); void object_add_completion(ReadLineState *rs, int nb_args, const char *str); void object_del_completion(ReadLineState *rs, int nb_args, const char *str); void device_add_completion(ReadLineState *rs, int nb_args, const char *str); diff --git a/qapi-schema.json b/qapi-schema.json index 2918fc4..9f9f097 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4744,3 +4744,11 @@ 'data': { 'filename' : 'str', '*epochs' : 'int', '*frequency': 'int' } } +## +# @log-dirty-bitmap-cancel +# +# cancel the dirty bitmap logging process +# +# Since 2.1 +## +{ 'command': 'log-dirty-bitmap-cancel' } diff --git a/qmp-commands.hx b/qmp-commands.hx index 183a636..2a8dacc 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3605,3 +3605,23 @@ value is 3 while that of frequency is 10. EQMP + { +.name = log-dirty-bitmap-cancel, +.args_type = , +.mhandler.cmd_new = qmp_marshal_input_log_dirty_bitmap_cancel, +}, + +SQMP +log_bitmap_cancel +-- + +Cancel the current bitmap dump process. + +Arguments: None. + +Example: + +- { execute: log-dirty-bitmap-cancel } +- { return: {} } + +EQMP diff --git a/savevm.c b/savevm.c index 675c8e5..ff87254 100644 --- a/savevm.c +++ b/savevm.c @@ -1260,6 +1260,25 @@ void qmp_log_dirty_bitmap(const char *filename, bool has_epochs, return; } +static void logging_bitmap_cancel(BitmapLogState *b) +{ +int old_state; +do { +old_state = b-state; +if (old_state != LOG_BITMAP_STATE_SETUP +old_state != LOG_BITMAP_STATE_ACTIVE) { +break; +} +logging_state_set_status(b, old_state, + LOG_BITMAP_STATE_CANCELING); +} while (b-state != LOG_BITMAP_STATE_CANCELING); +} + +void qmp_log_dirty_bitmap_cancel(Error **errp) +{ +logging_bitmap_cancel(logging_current_state()); +} + void qmp_xen_save_devices_state(const char *filename, Error **errp) { QEMUFile *f; -- 1.8.3.1
Re: [Qemu-devel] [PATCH] target-arm: implement PD0/PD1 bits for TTBCR
On 02 Jun 2014, at 18:02, Peter Maydell peter.mayd...@linaro.org wrote: On 30 May 2014 16:15, Fabian Aggeler aggel...@ethz.ch wrote: Corrected handling of writes to TTBCR for ARMv8 (previously UNK/SBZP bits are not RES0) and ARMv7 (new bits PD0/PD1 for CPUs with Security Extensions). Extracting T0SZ/T1SZ now uses 3 bits in Aarch32 and 6 bits in Aarch64 as bits [5:3] are now RES0 when writing to Aarch32 TTBCR, and not guaranteed to be zero anymore. Bits PD0/PD1 are now respected in get_phys_addr_lpae() and get_phys_addr_v6/v5(). Signed-off-by: Fabian Aggeler aggel...@ethz.ch --- Parts of this patch were previously part of the TZ patchset but were rewritten to include ARMv8 RES0 and PD0/PD1 handling. target-arm/cpu.h| 16 target-arm/helper.c | 70 + 2 files changed, 71 insertions(+), 15 deletions(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 17a1ddd..fc5771e 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -441,6 +441,22 @@ int arm_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw, /* Execution state bits. MRS read as zero, MSR writes ignored. */ #define CPSR_EXEC (CPSR_T | CPSR_IT | CPSR_J) +#define TTBCR_N (7U 0) /* TTBCR.EAE==0 */ +#define TTBCR_T0SZ (7U 0) /* TTBCR.EAE==1 */ +#define TTBCR_PD0(1U 4) +#define TTBCR_PD1(1U 5) +#define TTBCR_EPD0 (1U 7) +#define TTBCR_IRGN0 (3U 8) +#define TTBCR_ORGN0 (3U 10) +#define TTBCR_SH0(3U 12) +#define TTBCR_T1SZ (3U 16) +#define TTBCR_A1 (1U 22) +#define TTBCR_EPD1 (1U 23) +#define TTBCR_IRGN1 (3U 24) +#define TTBCR_ORGN1 (3U 26) +#define TTBCR_SH1(1U 28) +#define TTBCR_EAE(1U 31) + /* Bit definitions for ARMv8 SPSR (PSTATE) format. * Only these are valid when in AArch64 mode; in * AArch32 mode SPSRs are basically CPSR-format. diff --git a/target-arm/helper.c b/target-arm/helper.c index 4e52145..10b965e 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -312,7 +312,7 @@ static inline bool extended_addresses_enabled(CPUARMState *env) { return arm_el_is_aa64(env, 1) || ((arm_feature(env, ARM_FEATURE_LPAE) - (env-cp15.c2_control (1U 31; + (env-cp15.c2_control TTBCR_EAE))); } static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) @@ -1410,11 +1410,22 @@ static void vmsa_ttbcr_raw_write(CPUARMState *env, const ARMCPRegInfo *ri, { int maskshift = extract32(value, 0, 3); -if (arm_feature(env, ARM_FEATURE_LPAE) (value (1 31))) { -value = ~((7 19) | (3 14) | (0xf 3)); -} else { -value = 7; +if (!arm_feature(env, ARM_FEATURE_V8)){ Missing space before '{' (checkpatch finds this). Thanks for catching this. I will correct it in v2. +if (arm_feature(env, ARM_FEATURE_LPAE) (value TTBCR_EAE)) { +/* Pre ARMv8 bits [21:19], [15:14] and [6:3] are UNK/SBZP when + * using Long-desciptor translation table format */ +value = ~((7 19) | (3 14) | (0xf 3)); +} else if (arm_feature(env, ARM_FEATURE_EL3)) { +/* In an implementation that includes the Security Extensions + * TTBCR has additional fields PD0 [4] and PD1 [5] for + * Short-descriptor translation table format. + */ +value = TTBCR_PD1 | TTBCR_PD0 | TTBCR_N; +} else { +value = TTBCR_N; +} } + /* Note that we always calculate c2_mask and c2_base_mask, but * they are only used for short-descriptor tables (ie if EAE is 0); * for long-descriptor tables the TTBCR fields are used differently @@ -3670,15 +3681,18 @@ static inline int check_ap(CPUARMState *env, int ap, int domain_prot, } } -static uint32_t get_level1_table_address(CPUARMState *env, uint32_t address) +static uint32_t get_level1_table_address(CPUARMState *env, uint32_t address, + int *ttbr_id) { uint32_t table; -if (address env-cp15.c2_mask) +if (address env-cp15.c2_mask) { table = env-cp15.ttbr1_el1 0xc000; -else +*ttbr_id = 1; +} else { table = env-cp15.ttbr0_el1 env-cp15.c2_base_mask; - +*ttbr_id = 0; +} table |= (address 18) 0x3ffc; return table; } @@ -3691,6 +3705,7 @@ static int get_phys_addr_v5(CPUARMState *env, uint32_t address, int access_type, int code; uint32_t table; uint32_t desc; +int ttbr_id; int type; int ap; int domain; @@ -3699,7 +3714,14 @@ static int get_phys_addr_v5(CPUARMState *env, uint32_t address, int access_type, /* Pagetable walk. */ /* Lookup l1 descriptor. */ -table = get_level1_table_address(env, address); +table = get_level1_table_address(env, address, ttbr_id); +if ((ttbr_id == 0
Re: [Qemu-devel] [PATCH] target-arm: Prepare cpreg writefns/readfns for EL3/SecExt
On 31 May 2014, at 02:09, Peter Crosthwaite peter.crosthwa...@xilinx.com wrote: On Fri, May 16, 2014 at 10:43 PM, Fabian Aggeler aggel...@ethz.ch wrote: This patch changes some readfns/writefns to use raw_write and raw_read functions, wich use the fieldoffset specified which in ARMCPRegInfo instead of directly accessing the field. This will simplify patches for EL3 Security Extensions. Yes I like this idea is generally and universally. It makes the code more self documenting as these raw_write/raw_read sites clearly indicate that this is the actual register state value, which everything else in the fn is then side effects. It does also mean any renaming of variables in the env now only have to be changed twice (in the env and in the .fieldoffset of CPRegInfo) rather than three/four times (in read/write handlers as well). Signed-off-by: Fabian Aggeler aggel...@ethz.ch --- This patch was previously part of the Security Extension patchset but is not really Sec-Ext specific. target-arm/helper.c | 30 +++--- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index 417161e..6302d67 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -319,7 +319,7 @@ static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { ARMCPU *cpu = arm_env_get_cpu(env); -env-cp15.c3 = value; +raw_write(env, ri, value); tlb_flush(CPU(cpu), 1); /* Flush TLB as domain not tracked in TLB */ } @@ -327,12 +327,12 @@ static void fcse_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { ARMCPU *cpu = arm_env_get_cpu(env); -if (env-cp15.c13_fcse != value) { +if (raw_read(env, ri) != value) { /* Unlike real hardware the qemu TLB uses virtual addresses, * not modified virtual addresses, so this causes a TLB flush. */ tlb_flush(CPU(cpu), 1); -env-cp15.c13_fcse = value; +raw_write(env, ri, value); } } @@ -341,7 +341,7 @@ static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri, { ARMCPU *cpu = arm_env_get_cpu(env); -if (env-cp15.contextidr_el1 != value !arm_feature(env, ARM_FEATURE_MPU) +if (raw_read(env, ri) != value !arm_feature(env, ARM_FEATURE_MPU) !extended_addresses_enabled(env)) { /* For VMSA (when not using the LPAE long descriptor page table * format) this register includes the ASID, so do a TLB flush. @@ -349,7 +349,7 @@ static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri, */ tlb_flush(CPU(cpu), 1); } -env-cp15.contextidr_el1 = value; +raw_write(env, ri, value); } static void tlbiall_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -657,7 +657,7 @@ static void vbar_write(CPUARMState *env, const ARMCPRegInfo *ri, * contexts. (ARMv8 would permit us to do no masking at all, but ARMv7 * requires the bottom five bits to be RAZ/WI because they're UNK/SBZP.) */ -env-cp15.c12_vbar = value ~0x1FULL; +raw_write(env, ri, value ~0x1Ful); This one was already done in Edgar's series (now merged) so best to rebase to catch any other conflicts. But otherwise, Reviewed-by: Peter Crosthwaite peter.crosthwa...@xilinx.com Thanks, I will rebase and send v2 to avoid conflicts. Fabian } static uint64_t ccsidr_read(CPUARMState *env, const ARMCPRegInfo *ri) @@ -669,7 +669,7 @@ static uint64_t ccsidr_read(CPUARMState *env, const ARMCPRegInfo *ri) static void csselr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { -env-cp15.c0_cssel = value 0xf; +raw_write(env, ri, value 0xf); } static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri) @@ -1192,11 +1192,11 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { static void par_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { if (arm_feature(env, ARM_FEATURE_LPAE)) { -env-cp15.par_el1 = value; +raw_write(env, ri, value); } else if (arm_feature(env, ARM_FEATURE_V7)) { -env-cp15.par_el1 = value 0xf6ff; +raw_write(env, ri, value 0xf6ff); } else { -env-cp15.par_el1 = value 0xf1ff; +raw_write(env, ri, value 0xf1ff); } } @@ -1399,7 +1399,7 @@ static void vmsa_ttbcr_raw_write(CPUARMState *env, const ARMCPRegInfo *ri, * for long-descriptor tables the TTBCR fields are used differently * and the c2_mask and c2_base_mask values are meaningless. */ -env-cp15.c2_control = value; +raw_write(env, ri, value); env-cp15.c2_mask = ~(((uint32_t)0xu) maskshift); env-cp15.c2_base_mask = ~((uint32_t)0x3fffu maskshift); } @@ -1421,7 +1421,7 @@ static void vmsa_ttbcr_write(CPUARMState *env, const ARMCPRegInfo *ri, static void
Re: [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000
On Wed, Jun 4, 2014 at 3:09 AM, Paolo Bonzini pbonz...@redhat.com wrote: Il 04/06/2014 03:10, Jidong Xiao ha scritto: diff --git a/qemu-2.0.0/target-i386/kvm.c.orig b/qemu-2.0.0/target-i386/kvm.c index 4389959..b8b282d 100644 --- a/qemu-2.0.0/target-i386/kvm.c.orig +++ b/qemu-2.0.0/target-i386/kvm.c @@ -530,7 +530,7 @@ int kvm_arch_init_vcpu(CPUState *cs) memcpy(signature, KVMKVMKVM\0\0\0, 12); c = cpuid_data.entries[cpuid_i++]; c-function = KVM_CPUID_SIGNATURE | kvm_base; -c-eax = 0; + c-eax = KVM_CPUID_FEATURES; c-ebx = signature[0]; c-ecx = signature[1]; c-edx = signature[2]; This should actually be KVM_CPUID_FEATURES | kvm_base, in case Hyper-V leaves are available too. But it is a good catch! Paolo Thanks Paolo. I have just added that and resend the patch as following: -Jidong === Signed-off-by: Jidong Xiao jidong.x...@gmail.com --- diff --git a/qemu-2.0.0/target-i386/kvm.c.orig b/qemu-2.0.0/target-i386/kvm.c index 4389959..fe49a75 100644 --- a/qemu-2.0.0/target-i386/kvm.c.orig +++ b/qemu-2.0.0/target-i386/kvm.c @@ -530,7 +530,7 @@ int kvm_arch_init_vcpu(CPUState *cs) memcpy(signature, KVMKVMKVM\0\0\0, 12); c = cpuid_data.entries[cpuid_i++]; c-function = KVM_CPUID_SIGNATURE | kvm_base; -c-eax = 0; + c-eax = KVM_CPUID_FEATURES | kvm_base; c-ebx = signature[0]; c-ecx = signature[1]; c-edx = signature[2];
Re: [Qemu-devel] [PATCH microblaze v1 0/6] Microblaze Device QOM cleanups
On Thu, May 29, 2014 at 02:21:52AM -0700, Peter Crosthwaite wrote: Hi Andreas, Edgar, Hi Peter, This looks good to me. I'm afk most of this and the next week but will give run tests and put in my queue after that. Unless Andreas wants to take it through his queue. Thanks, Edgar Another 4 users of SysBusDevice::init bite the dust! A round of styling cleanup for Microblaze devices as per QOM conventions. Tested with published MB test images. Regards, Peter Peter Crosthwaite (6): timer: xilinx_timer: Convert to realize() net: xilinx_ethlite: Don't reset from init net: xilinx_ethlite: Convert to realize() char: xilinx_uartlite: Don't reset from init char: xilinx_uartlite: Convert to realize() intc: xilinx_uartlite: Convert SBD::init - instance_init hw/char/xilinx_uartlite.c | 32 +--- hw/intc/xilinx_intc.c | 17 +++-- hw/net/xilinx_ethlite.c | 34 ++ hw/timer/xilinx_timer.c | 20 4 files changed, 62 insertions(+), 41 deletions(-) -- 1.9.3.1.ga73a6ad
[Qemu-devel] [PATCH v2 5/8] hmp interface for dirty bitmap dump
Signed-off-by: Sanidhya Kashyap sanidhya.ii...@gmail.com --- hmp-commands.hx | 16 hmp.c | 16 hmp.h | 1 + 3 files changed, 33 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 2e462c0..1665587 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1780,6 +1780,22 @@ STEXI show available trace events and their state ETEXI + { +.name = ldb|log-dirty-bitmap, +.args_type = filename:s,epochs:i?,frequency:i?, +.params = filename epochs frequency, +.help = dumps the memory's dirty bitmap to file\n\t\t\t + filename: name of the file in which the bitmap will be saved\n\t\t\t + epochs: number of times, the memory will be logged\n\t\t\t + frequency: time difference in milliseconds between each epoch, +.mhandler.cmd = hmp_log_dirty_bitmap, +}, +STEXI +@item ldb or log-dirty-bitmap @var{filename} +@findex log-dirty-bitmap +dumps the writable working set of a VM's memory to a file +ETEXI + STEXI @end table ETEXI diff --git a/hmp.c b/hmp.c index ccc35d4..a400825 100644 --- a/hmp.c +++ b/hmp.c @@ -1314,6 +1314,22 @@ void hmp_device_del(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, err); } +void hmp_log_dirty_bitmap(Monitor *mon, const QDict *qdict) +{ +const char *filename = qdict_get_str(qdict, filename); +int64_t epochs = qdict_get_try_int(qdict, epochs, 3); +int64_t frequency = qdict_get_try_int(qdict, frequency, 10); +Error *err = NULL; + +qmp_log_dirty_bitmap(filename, !!epochs, epochs, !!frequency, + frequency, err); +if (err) { +monitor_printf(mon, log-dirty-bitmap: %s\n, error_get_pretty(err)); +error_free(err); +return; +} +} + void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) { Error *err = NULL; diff --git a/hmp.h b/hmp.h index aba59e9..3a79a93 100644 --- a/hmp.h +++ b/hmp.h @@ -93,6 +93,7 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict); void hmp_cpu_add(Monitor *mon, const QDict *qdict); void hmp_object_add(Monitor *mon, const QDict *qdict); void hmp_object_del(Monitor *mon, const QDict *qdict); +void hmp_log_dirty_bitmap(Monitor *mon, const QDict *qdict); void object_add_completion(ReadLineState *rs, int nb_args, const char *str); void object_del_completion(ReadLineState *rs, int nb_args, const char *str); void device_add_completion(ReadLineState *rs, int nb_args, const char *str); -- 1.8.3.1
Re: [Qemu-devel] [PATCH] target-microblaze: Delete unused sign_extend() function
On Tue, Jun 03, 2014 at 06:59:21PM +0100, Peter Maydell wrote: The sign_extend() function is unused; delete it. Reviewed-by: Edgar E. Iglesias edgar.igles...@xilinx.com Peter, feel free to push this straight in. Thanks, Edgar Signed-off-by: Peter Maydell peter.mayd...@linaro.org --- We have sextract() for this these days anyway. --- target-microblaze/translate.c | 13 - 1 file changed, 13 deletions(-) diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c index 488df2d..50c214b 100644 --- a/target-microblaze/translate.c +++ b/target-microblaze/translate.c @@ -98,19 +98,6 @@ static const char *special_regnames[] = sr16, sr17, sr18 }; -/* Sign extend at translation time. */ -static inline int sign_extend(unsigned int val, unsigned int width) -{ -int sval; - -/* LSL. */ -val = 31 - width; -sval = val; -/* ASR. */ -sval = 31 - width; -return sval; -} - static inline void t_sync_flags(DisasContext *dc) { /* Synch the tb dependent flags between translator and runtime. */ -- 1.9.2
Re: [Qemu-devel] [PATCH 0/5] gtk: fixes, cleanups and text consoles without vte
Am 03.06.2014 10:01, schrieb Gerd Hoffmann: Hi, Current gtk patch queue. A bunch of cleanups and fixes. Most notable change is patch #5 which winds up qemu text terminal emulation in gtk, so '-chardev vc' works even when building without vte (i.e. on windows). Gerd Hoffmann (5): gtk: factor out keycode mapping gtk: cleanup backend dependencies gtk: factor out gtk3 grab into the new gd_grab_devices function gtk: update window size after showing/hiding tabs gtk: bind to text terminal consoles too configure | 4 + ui/gtk.c | 298 ++ 2 files changed, 170 insertions(+), 132 deletions(-) Hi Gerd, its great to get text terminals without VTE now. I tested the series on a Linux x86_64 host. Native QEMU for this host seems to work fine. QEMU for 64 bit Windows with wine64 shows several issues: * The text consoles are named vc1, vc2, vc3 in the menu. * The text consoles show a black left border initially. * Booting a Linux guest is extremely slow. I see several timeouts: err:ntdll:RtlpWaitForCriticalSection section 0x9a9560 ? wait timed out in thread 0030, blocked by 002c, retrying (60 sec) Regards Stefan
Re: [Qemu-devel] [PATCH v1 13/16] target-arm: A64: Emulate the HVC insn
Edgar E. Iglesias writes: On Tue, Jun 03, 2014 at 11:41:25AM +0100, Alex Bennée wrote: Edgar E. Iglesias writes: static inline void arm_log_exception(int idx) @@ -204,6 +205,11 @@ static inline uint32_t syn_aa64_svc(uint32_t imm16) return (EC_AA64_SVC ARM_EL_EC_SHIFT) | ARM_EL_IL | (imm16 0x); } +static inline uint32_t syn_aa64_hvc(uint32_t imm16) +{ +return (EC_AA64_HVC ARM_EL_EC_SHIFT) | ARM_EL_IL | (imm16 0x); +} The mask seems superfluous (as it is for arm_log_exception) Sorry, can you clarify what you mean here? Are you refering to the imm16? Yes the imm16. It's the result of an extract32(..,..,16) so I can't see how it wouldn't already be correctly masked. -- Alex Bennée
[Qemu-devel] [RFC PATCH V2 0/2] support xen HVM direct kernel boot
After your valuable suggestions, I'll continue the work to support stubdom. But since stubdom currently uses qemu-xen-traditional and will switch to qemu upstream in future, in a period of time, stubdom HVM direct kernel boot won't be in working status. So, before continuing the stubdom support work, I updated existing patch series, adding proper error messages for rombios and stubdom limitation, adding man page descriptions and other trival updates to make it a complete working patch series. For those using seabios and non stubdom, they can use now. xen side patch: pass kernel/initrd/append parameters to qemu-dm qemu side patch: reuse load_linux() for xen hvm direct kernel boot. Different from pc_memory_init which does lots of ram alloc work and rom/bios loading work, for xen, we only need to init a basic fw_cfg device used by load_linux() to store ADDRs and linuxboot.bin/multiboot.bin to retrive ADDRs, then load_linux(), after that, do real add option rom work to add linuxboot.bin/multiboot.bin to system option rom. Other things would be done by seabios smoothly. v1 is here: http://lists.gnu.org/archive/html/qemu-devel/2014-05/msg06233.html Chunyan Liu (2): xen: pass kernel initrd to qemu qemu: support xen hvm direct kernel boot
[Qemu-devel] [RFC PATCH V2 1/2] xen: pass kernel initrd to qemu
xen side patch to support xen HVM direct kernel boot: support 'kernel', 'ramdisk', 'root', 'extra' in HVM config file, parse config file, pass -kernel, -initrd, -append parameters to qemu. It's working with seabios and non-stubdom. Rombios and stubdom cases are currently not supported. [config example] kernel=/mnt/vmlinuz-3.0.13-0.27-default ramdisk=/mnt/initrd-3.0.13-0.27-default root=/dev/hda2 extra=console=tty0 console=ttyS0 disk=[ 'file:/mnt/images/bjz_04_sles11_sp2/disk0.raw,hda,w', ] Signed-off-by: Chunyan Liu cy...@suse.com --- Changes: * update man page to document the new parameters for HVM guests (move them from PV special options to general options) and note current limitation * rombios and stubdom are not working yet, add libxl error messages to inform that. * extract parse commandline code to a common helper for both HVM and PV parse_config_data to use. docs/man/xl.cfg.pod.5 | 50 tools/libxl/libxl_dm.c | 15 tools/libxl/libxl_types.idl | 3 +++ tools/libxl/xl_cmdimpl.c| 56 +++-- 4 files changed, 82 insertions(+), 42 deletions(-) diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5 index 0ca37bc..c585801 100644 --- a/docs/man/xl.cfg.pod.5 +++ b/docs/man/xl.cfg.pod.5 @@ -304,6 +304,34 @@ Action to take if the domain crashes. Default is Cdestroy. =back +=head3 Direct Kernel Boot + +Currently, direct kernel boot can be supported by PV guests, and HVM guests +in limitation. For HVM guests, in case of stubdom-dm and old rombios, +direct kernel boot is not supported. + +=over 4 + +=item Bkernel=PATHNAME + +Load the specified file as the kernel image. + +=item Bramdisk=PATHNAME + +Load the specified file as the ramdisk. + +=item Broot=STRING + +Append Broot=STRING to the kernel command line (Note: it is guest +specific what meaning this has). + +=item Bextra=STRING + +Append BSTRING to the kernel command line. (Note: it is guest +specific what meaning this has). + +=back + =head3 Other Options =over 4 @@ -647,20 +675,12 @@ The following options apply only to Paravirtual guests. =over 4 -=item Bkernel=PATHNAME - -Load the specified file as the kernel image. Either Bkernel or -Bbootloader must be specified for PV guests. - -=item Bramdisk=PATHNAME - -Load the specified file as the ramdisk. - =item Bbootloader=PROGRAM Run CPROGRAM to find the kernel image and ramdisk to use. Normally CPROGRAM would be Cpygrub, which is an emulation of -grub/grub2/syslinux. +grub/grub2/syslinux. Either Bkernel or Bbootloader must be specified +for PV guests. =item Bbootloader_args=[ ARG, ARG, ...] @@ -668,16 +688,6 @@ Append BARGs to the arguments to the Bbootloader program. Alternatively if the argument is a simple string then it will be split into words at whitespace (this second option is deprecated). -=item Broot=STRING - -Append Broot=STRING to the kernel command line (Note: it is guest -specific what meaning this has). - -=item Bextra=STRING - -Append BSTRING to the kernel command line. Note: it is guest -specific what meaning this has). - =item Be820_host=BOOLEAN Selects whether to expose the host e820 (memory map) to the guest via diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 51ab2bf..c2eaa54 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -196,6 +196,12 @@ static char ** libxl__build_device_model_args_old(libxl__gc *gc, int nr_set_cpus = 0; char *s; +if (b_info-u.hvm.kernel) { +LOG(ERROR, %s: direct kernel boot is not supported by %s, +__func__, dm); +return NULL; +} + if (b_info-u.hvm.serial) { flexarray_vappend(dm_args, -serial, b_info-u.hvm.serial, NULL); } @@ -479,6 +485,15 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc, if (b_info-type == LIBXL_DOMAIN_TYPE_HVM) { int ioemu_nics = 0; +if (b_info-u.hvm.kernel) +flexarray_vappend(dm_args, -kernel, b_info-u.hvm.kernel, NULL); + +if (b_info-u.hvm.ramdisk) +flexarray_vappend(dm_args, -initrd, b_info-u.hvm.ramdisk, NULL); + +if (b_info-u.hvm.cmdline) +flexarray_vappend(dm_args, -append, b_info-u.hvm.cmdline, NULL); + if (b_info-u.hvm.serial) { flexarray_vappend(dm_args, -serial, b_info-u.hvm.serial, NULL); } diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 52f1aa9..a96b228 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -336,6 +336,9 @@ libxl_domain_build_info = Struct(domain_build_info,[ (event_channels, uint32), (u, KeyedUnion(None, libxl_domain_type, type, [(hvm, Struct(None, [(firmware, string), + (kernel, string), + (cmdline,
[Qemu-devel] [RFC PATCH V2 2/2] qemu: support xen hvm direct kernel boot
qemu side patch to support xen HVM direct kernel boot: if -kernel exists, calls xen_load_linux(), which will read kernel/initrd and add a linuxboot.bin or multiboot.bin option rom. The linuxboot.bin/multiboot.bin will load kernel/initrd and jump to execute kernel directly. It's working when xen uses seabios. Signed-off-by: Chunyan Liu cy...@suse.com --- Changes: * remove kvmvpaic.bin from xen option_rom by hacking: +s-vapic_control = 0; rather than the way of checking and bypassing it in xen_load_linux(). hw/i386/pc.c | 22 ++ hw/i386/pc_piix.c | 7 +++ hw/i386/xen/xen_apic.c | 1 + include/hw/i386/pc.h | 5 + 4 files changed, 35 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e6369d5..bc04fe4 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1187,6 +1187,28 @@ void pc_acpi_init(const char *default_dsdt) } } +FWCfgState *xen_load_linux(const char *kernel_filename, + const char *kernel_cmdline, + const char *initrd_filename, + ram_addr_t below_4g_mem_size, + PcGuestInfo *guest_info) +{ +int i; +FWCfgState *fw_cfg; + +assert(kernel_filename != NULL); + +fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0); +rom_set_fw(fw_cfg); + +load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdline, below_4g_mem_size); +for (i = 0; i nb_option_roms; i++) { +rom_add_option(option_rom[i].name, option_rom[i].bootindex); +} +guest_info-fw_cfg = fw_cfg; +return fw_cfg; +} + FWCfgState *pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline, diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index a48e263..93b8d93 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -158,6 +158,13 @@ static void pc_init1(MachineState *machine, machine-initrd_filename, below_4g_mem_size, above_4g_mem_size, rom_memory, ram_memory, guest_info); +} else if (args-kernel_filename != NULL) { +/* For xen HVM direct kernel boot, load linux here */ +fw_cfg = xen_load_linux(args-kernel_filename, +args-kernel_cmdline, +args-initrd_filename, +below_4g_mem_size, +guest_info); } gsi_state = g_malloc0(sizeof(*gsi_state)); diff --git a/hw/i386/xen/xen_apic.c b/hw/i386/xen/xen_apic.c index 63bb7f7..f5acd6a 100644 --- a/hw/i386/xen/xen_apic.c +++ b/hw/i386/xen/xen_apic.c @@ -40,6 +40,7 @@ static void xen_apic_realize(DeviceState *dev, Error **errp) { APICCommonState *s = APIC_COMMON(dev); +s-vapic_control = 0; memory_region_init_io(s-io_memory, OBJECT(s), xen_apic_io_ops, s, xen-apic-msi, APIC_SPACE_SIZE); diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 32a7687..e472184 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -134,6 +134,11 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size, void pc_pci_as_mapping_init(Object *owner, MemoryRegion *system_memory, MemoryRegion *pci_address_space); +FWCfgState *xen_load_linux(const char *kernel_filename, + const char *kernel_cmdline, + const char *initrd_filename, + ram_addr_t below_4g_mem_size, + PcGuestInfo *guest_info); FWCfgState *pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline, -- 1.8.4.5
Re: [Qemu-devel] [PATCH 0/5] gtk: fixes, cleanups and text consoles without vte
Hi Gerd, its great to get text terminals without VTE now. I tested the series on a Linux x86_64 host. Native QEMU for this host seems to work fine. QEMU for 64 bit Windows with wine64 shows several issues: * The text consoles are named vc1, vc2, vc3 in the menu. Yep. It's because we don't have access to the chardev. Fixing that (non-hackish) needs some infrastructure work: * Make chardevs objects, link them in the qom tree. * Make chardev label a object property. * Add a chardev link to QemuConsoles (simliar to the device link we have today for gfx consoles). Then we can figure a better name in the ui. * Booting a Linux guest is extremely slow. I see several timeouts: err:ntdll:RtlpWaitForCriticalSection section 0x9a9560 ? wait timed out in thread 0030, Hmm. No idea. But its pretty much a blocker given that this stuff will be active on windows by default. Tried real windows too? Any chance to get a stacktrace for the place where it blocks? Maybe that gives a clue ... thanks, Gerd
[Qemu-devel] [PULL 5/7] docs/multiseat.txt: use autoseat
When using the autoseat feature of systemd/logind we'll only need a single udev rule for the pci bridge, which simplifies the guest setup a bit. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- docs/multiseat.txt | 54 +++--- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/docs/multiseat.txt b/docs/multiseat.txt index a6c71dd..126f39d 100644 --- a/docs/multiseat.txt +++ b/docs/multiseat.txt @@ -46,29 +46,37 @@ You need a pretty recent linux guest. systemd with loginctl. kernel fully updated for the new kernel though, i.e. the live iso doesn't cut it. -Now we'll have to configure the guest. Boot and login. By default -all devices belong to seat0. You can use loginctl seat-status seat0 -to list them all (and to get the sysfs paths for cut+paste). Now -we'll go assign all pci devices connected the pci bridge in slot 12 to -a new head: - -loginctl attach seat-qemu \ -/sys/devices/pci:00/:00:12.0/:01:02.0/drm/card1 -loginctl attach seat-qemu \ -/sys/devices/pci:00/:00:12.0/:01:02.0/graphics/fb1 -loginctl attach seat-qemu \ -/sys/devices/pci:00/:00:12.0/:01:0f.0/usb2 - -Use loginctl seat-status seat-qemu to check the result. It isn't -needed to assign the usb devices to the head individually, assigning a -usb (root) hub will automatically assign all usb devices connected to -it too. - -BTW: loginctl writes udev rules to /etc/udev/rules.d to make these -device assignments permanent, so you need to do this only once. - -Now simply restart gdm (rebooting will do too), and a login screen -should show up on the second head. +Now we'll have to configure the guest. Boot and login. lspci -vt +should list the pci bridge with the display adapter and usb controller: + +[root@fedora ~]# lspci -vt +-[:00]-+-00.0 Intel Corporation 440FX - 82441FX PMC [Natoma] + [ ... ] + \-12.0-[01]--+-02.0 Device 1234: +\-0f.0 NEC Corporation USB 3.0 Host Controller + +Good. Now lets tell the system that the pci bridge and all devices +below it belong to a separate seat by dropping a file into +/etc/udev/rules.d: + +[root@fedora ~]# cat /etc/udev/rules.d/70-qemu-autoseat.rules +SUBSYSTEMS==pci, DEVPATH==*/:00:12.0, TAG+=seat, ENV{ID_AUTOSEAT}=1 + +Reboot. System should come up with two seats. With loginctl you can +check the configuration: + +[root@fedora ~]# loginctl list-seats +SEAT +seat0 +seat-pci-pci-_00_12_0 + +2 seats listed. + +You can use loginctl seat-status seat-pci-pci-_00_12_0 to list +the devices attached to the seat. + +Background info is here: + http://www.freedesktop.org/wiki/Software/systemd/multiseat/ Enjoy! -- 1.8.3.1
[Qemu-devel] [PULL 4/7] input/vnc: use kbd delays in press_key
Signed-off-by: Gerd Hoffmann kra...@redhat.com --- ui/vnc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/vnc.c b/ui/vnc.c index 61b1f93..1684206 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1553,7 +1553,9 @@ static void press_key(VncState *vs, int keysym) { int keycode = keysym2scancode(vs-vd-kbd_layout, keysym) SCANCODE_KEYMASK; qemu_input_event_send_key_number(vs-vd-dcl.con, keycode, true); +qemu_input_event_send_key_delay(0); qemu_input_event_send_key_number(vs-vd-dcl.con, keycode, false); +qemu_input_event_send_key_delay(0); } static int current_led_state(VncState *vs) -- 1.8.3.1
[Qemu-devel] [PULL 0/7] input patch queue
Hi, This pull adds the keyboard delay support for the input layer and it updates the multiseat.txt doc file. please pull, Gerd The following changes since commit e00fcfeab3d452cba3d0a08991a39ab15df66424: Merge remote-tracking branch 'remotes/awilliam/tags/vfio-pci-for-qemu-20140602.0' into staging (2014-06-03 14:37:43 +0100) are available in the git repository at: git://git.kraxel.org/qemu tags/pull-input-10 for you to fetch changes up to 2082bac151f9ed17f4425a3dbe994ed0b7958c89: docs/multiseat.txt: add note about spice (2014-06-04 08:40:42 +0200) updates for docs/multiseat.txt input: add support for kbd delays Gerd Hoffmann (7): input: add support for kbd delays input: use kbd delays for send_key monitor command input/curses: add kbd delay between keydown and keyup events input/vnc: use kbd delays in press_key docs/multiseat.txt: use autoseat docs/multiseat.txt: gtk joined the party docs/multiseat.txt: add note about spice docs/multiseat.txt | 78 +- include/ui/input.h | 1 + ui/curses.c| 10 + ui/input-legacy.c | 45 +++--- ui/input.c | 108 +++-- ui/vnc.c | 2 + 6 files changed, 176 insertions(+), 68 deletions(-)
[Qemu-devel] [PULL 3/7] input/curses: add kbd delay between keydown and keyup events
Signed-off-by: Gerd Hoffmann kra...@redhat.com --- ui/curses.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/ui/curses.c b/ui/curses.c index de85f76..8edb038 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -277,31 +277,41 @@ static void curses_refresh(DisplayChangeListener *dcl) * events, we need to emit both for each key received */ if (keycode SHIFT) { qemu_input_event_send_key_number(NULL, SHIFT_CODE, true); +qemu_input_event_send_key_delay(0); } if (keycode CNTRL) { qemu_input_event_send_key_number(NULL, CNTRL_CODE, true); +qemu_input_event_send_key_delay(0); } if (keycode ALT) { qemu_input_event_send_key_number(NULL, ALT_CODE, true); +qemu_input_event_send_key_delay(0); } if (keycode ALTGR) { qemu_input_event_send_key_number(NULL, GREY | ALT_CODE, true); +qemu_input_event_send_key_delay(0); } qemu_input_event_send_key_number(NULL, keycode KEY_MASK, true); +qemu_input_event_send_key_delay(0); qemu_input_event_send_key_number(NULL, keycode KEY_MASK, false); +qemu_input_event_send_key_delay(0); if (keycode ALTGR) { qemu_input_event_send_key_number(NULL, GREY | ALT_CODE, false); +qemu_input_event_send_key_delay(0); } if (keycode ALT) { qemu_input_event_send_key_number(NULL, ALT_CODE, false); +qemu_input_event_send_key_delay(0); } if (keycode CNTRL) { qemu_input_event_send_key_number(NULL, CNTRL_CODE, false); +qemu_input_event_send_key_delay(0); } if (keycode SHIFT) { qemu_input_event_send_key_number(NULL, SHIFT_CODE, false); +qemu_input_event_send_key_delay(0); } } else { keysym = curses2qemu[chr]; -- 1.8.3.1
[Qemu-devel] [PULL 7/7] docs/multiseat.txt: add note about spice
Signed-off-by: Gerd Hoffmann kra...@redhat.com --- docs/multiseat.txt | 8 1 file changed, 8 insertions(+) diff --git a/docs/multiseat.txt b/docs/multiseat.txt index dd3a831..67151e0 100644 --- a/docs/multiseat.txt +++ b/docs/multiseat.txt @@ -47,6 +47,14 @@ in a separate tab. You can either simply switch tabs to switch heads, or use the View / Detach tab menu item to move one of the displays to its own window so you can see both display devices side-by-side. +Note on spice: Spice handles multihead just fine. But it can't do +multiseat. For tablet events the event source is sent to the spice +agent. But qemu can't figure it, so it can't do input routing. +Fixing this needs a new or extended input interface between +libspice-server and qemu. For keyboard events it is even worse: The +event source isn't included in the spice protocol, so the wire +protocol must be extended to support this. + guest side -- -- 1.8.3.1
[Qemu-devel] [PULL 2/7] input: use kbd delays for send_key monitor command
Signed-off-by: Gerd Hoffmann kra...@redhat.com --- ui/input-legacy.c | 45 ++--- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/ui/input-legacy.c b/ui/input-legacy.c index 2a53860..3025f50 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -74,27 +74,6 @@ int index_from_key(const char *key) return i; } -static KeyValue **keyvalues; -static int keyvalues_size; -static QEMUTimer *key_timer; - -static void free_keyvalues(void) -{ -g_free(keyvalues); -keyvalues = NULL; -keyvalues_size = 0; -} - -static void release_keys(void *opaque) -{ -while (keyvalues_size 0) { -qemu_input_event_send_key(NULL, keyvalues[--keyvalues_size], - false); -} - -free_keyvalues(); -} - static KeyValue *copy_key_value(KeyValue *src) { KeyValue *dst = g_new(KeyValue, 1); @@ -107,30 +86,18 @@ void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_time, { KeyValueList *p; -if (!key_timer) { -key_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, release_keys, NULL); -} - -if (keyvalues != NULL) { -timer_del(key_timer); -release_keys(NULL); -} - if (!has_hold_time) { -hold_time = 100; +hold_time = 0; /* use default */ } for (p = keys; p != NULL; p = p-next) { qemu_input_event_send_key(NULL, copy_key_value(p-value), true); - -keyvalues = g_realloc(keyvalues, sizeof(KeyValue *) * - (keyvalues_size + 1)); -keyvalues[keyvalues_size++] = copy_key_value(p-value); +qemu_input_event_send_key_delay(hold_time); +} +for (p = keys; p != NULL; p = p-next) { +qemu_input_event_send_key(NULL, copy_key_value(p-value), false); +qemu_input_event_send_key_delay(hold_time); } - -/* delayed key up events */ -timer_mod(key_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + - muldiv64(get_ticks_per_sec(), hold_time, 1000)); } static void legacy_kbd_event(DeviceState *dev, QemuConsole *src, -- 1.8.3.1
[Qemu-devel] [PULL 1/7] input: add support for kbd delays
Signed-off-by: Gerd Hoffmann kra...@redhat.com --- include/ui/input.h | 1 + ui/input.c | 108 +++-- 2 files changed, 106 insertions(+), 3 deletions(-) diff --git a/include/ui/input.h b/include/ui/input.h index aa99b0c..5d5ac00 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -39,6 +39,7 @@ InputEvent *qemu_input_event_new_key(KeyValue *key, bool down); void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down); void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down); void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down); +void qemu_input_event_send_key_delay(uint32_t delay_ms); int qemu_input_key_number_to_qcode(uint8_t nr); int qemu_input_key_value_to_number(const KeyValue *value); int qemu_input_key_value_to_qcode(const KeyValue *value); diff --git a/ui/input.c b/ui/input.c index 14c9434..89d9db7 100644 --- a/ui/input.c +++ b/ui/input.c @@ -14,11 +14,31 @@ struct QemuInputHandlerState { QemuConsole *con; QTAILQ_ENTRY(QemuInputHandlerState) node; }; + +typedef struct QemuInputEventQueue QemuInputEventQueue; +struct QemuInputEventQueue { +enum { +QEMU_INPUT_QUEUE_DELAY = 1, +QEMU_INPUT_QUEUE_EVENT, +QEMU_INPUT_QUEUE_SYNC, +} type; +QEMUTimer *timer; +uint32_t delay_ms; +QemuConsole *src; +InputEvent *evt; +QTAILQ_ENTRY(QemuInputEventQueue) node; +}; + static QTAILQ_HEAD(, QemuInputHandlerState) handlers = QTAILQ_HEAD_INITIALIZER(handlers); static NotifierList mouse_mode_notifiers = NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers); +static QTAILQ_HEAD(QemuInputEventQueueHead, QemuInputEventQueue) kbd_queue = +QTAILQ_HEAD_INITIALIZER(kbd_queue); +static QEMUTimer *kbd_timer; +static uint32_t kbd_default_delay_ms = 10; + QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev, QemuInputHandler *handler) { @@ -171,6 +191,73 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt) } } +static void qemu_input_queue_process(void *opaque) +{ +struct QemuInputEventQueueHead *queue = opaque; +QemuInputEventQueue *item; + +g_assert(!QTAILQ_EMPTY(queue)); +item = QTAILQ_FIRST(queue); +g_assert(item-type == QEMU_INPUT_QUEUE_DELAY); +QTAILQ_REMOVE(queue, item, node); +g_free(item); + +while (!QTAILQ_EMPTY(queue)) { +item = QTAILQ_FIRST(queue); +switch (item-type) { +case QEMU_INPUT_QUEUE_DELAY: +timer_mod(item-timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + + item-delay_ms); +return; +case QEMU_INPUT_QUEUE_EVENT: +qemu_input_event_send(item-src, item-evt); +qapi_free_InputEvent(item-evt); +break; +case QEMU_INPUT_QUEUE_SYNC: +qemu_input_event_sync(); +break; +} +QTAILQ_REMOVE(queue, item, node); +g_free(item); +} +} + +static void qemu_input_queue_delay(struct QemuInputEventQueueHead *queue, + QEMUTimer *timer, uint32_t delay_ms) +{ +QemuInputEventQueue *item = g_new0(QemuInputEventQueue, 1); +bool start_timer = QTAILQ_EMPTY(queue); + +item-type = QEMU_INPUT_QUEUE_DELAY; +item-delay_ms = delay_ms; +item-timer = timer; +QTAILQ_INSERT_TAIL(queue, item, node); + +if (start_timer) { +timer_mod(item-timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + + item-delay_ms); +} +} + +static void qemu_input_queue_event(struct QemuInputEventQueueHead *queue, + QemuConsole *src, InputEvent *evt) +{ +QemuInputEventQueue *item = g_new0(QemuInputEventQueue, 1); + +item-type = QEMU_INPUT_QUEUE_EVENT; +item-src = src; +item-evt = evt; +QTAILQ_INSERT_TAIL(queue, item, node); +} + +static void qemu_input_queue_sync(struct QemuInputEventQueueHead *queue) +{ +QemuInputEventQueue *item = g_new0(QemuInputEventQueue, 1); + +item-type = QEMU_INPUT_QUEUE_SYNC; +QTAILQ_INSERT_TAIL(queue, item, node); +} + void qemu_input_event_send(QemuConsole *src, InputEvent *evt) { QemuInputHandlerState *s; @@ -230,9 +317,14 @@ void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down) { InputEvent *evt; evt = qemu_input_event_new_key(key, down); -qemu_input_event_send(src, evt); -qemu_input_event_sync(); -qapi_free_InputEvent(evt); +if (QTAILQ_EMPTY(kbd_queue)) { +qemu_input_event_send(src, evt); +qemu_input_event_sync(); +qapi_free_InputEvent(evt); +} else { +qemu_input_queue_event(kbd_queue, src, evt); +qemu_input_queue_sync(kbd_queue); +} } void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down) @@ -251,6 +343,16 @@ void qemu_input_event_send_key_qcode(QemuConsole *src,
[Qemu-devel] [PATCH v2] linux-user/signal.c: define __SIGRTMIN/MAX for non-GNU platforms
The __SIGRTMIN and __SIGRTMAX are glibc internals and are not available on all platforms, so we define those if they are missing. We also check that those corresponds with the posix variables SIGRTMIN/SIGRTMAX which may only be available during runtime. This is needed for musl libc. Signed-off-by: Natanael Copa nc...@alpinelinux.org --- Changes v1 - v2: - replace NSIG with _NSIG since thats use everywhere else in the code. - add runtime asserts. linux-user/signal.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/linux-user/signal.c b/linux-user/signal.c index 5b8a01f..67771ad 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -32,6 +32,13 @@ //#define DEBUG_SIGNAL +#ifndef __SIGRTMIN +#define __SIGRTMIN 32 +#endif +#ifndef __SIGRTMAX +#define __SIGRTMAX (_NSIG-1) +#endif + static struct target_sigaltstack target_sigaltstack_used = { .ss_sp = 0, .ss_size = 0, @@ -379,6 +386,13 @@ void signal_init(void) int i, j; int host_sig; +/* SIGRTMIN/SIGRTMAX might be runtime variables so we cannot use them + to declare the host_to_target_signal table. But we are interacting + with a given kernel where the values will be fixed. Check that the + runtime values actually corresponds. */ +assert(__SIGRTMIN == SIGRTMIN); +assert(__SIGRTMAX == SIGRTMAX); + /* generate signal conversion tables */ for(i = 1; i _NSIG; i++) { if (host_to_target_signal_table[i] == 0) -- 2.0.0
Re: [Qemu-devel] [PATCH v2 4/8] linux-user: arm: handle CPSR.E correctly in strex emulation
Il 03/06/2014 11:54, Peter Maydell ha scritto: In system emulation it's clear how we should implement things: TARGET_WORDS_BIGENDIAN is never set, data accesses honour CPSR.E by doing MO_BE or MO_LE accesses, instruction accesses are always MO_LE, and SCTLR.B is implemented by XORing the address with 3 (for byte accesses) or 1 (for halfword accesses). I think it's 2 for halfword accesses. :) What about 64-bit accesses? Does the processor swap the two words of the result? Paolo
[Qemu-devel] [PULL 6/7] docs/multiseat.txt: gtk joined the party
Signed-off-by: Gerd Hoffmann kra...@redhat.com --- docs/multiseat.txt | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/multiseat.txt b/docs/multiseat.txt index 126f39d..dd3a831 100644 --- a/docs/multiseat.txt +++ b/docs/multiseat.txt @@ -6,16 +6,20 @@ host side - First you must compile qemu with a user interface supporting -multihead/multiseat and input event routing. Right now this list is -pretty short: sdl2. +multihead/multiseat and input event routing. Right now this +list includes sdl2 and gtk (both 2+3): ./configure --enable-sdl --with-sdlabi=2.0 +or + + ./configure --enable-gtk + Next put together the qemu command line: qemu -enable-kvm -usb $memory $disk $whatever \ - -display sdl \ + -display [ sdl | gtk ] \ -vga std \ -device usb-tablet @@ -37,6 +41,12 @@ The display=video2 sets up the input routing. Any input coming from the window which belongs to the video.2 display adapter will be routed to these input devices. +The sdl2 ui will start up with two windows, one for each display +device. The gtk ui will start with a single window and each display +in a separate tab. You can either simply switch tabs to switch heads, +or use the View / Detach tab menu item to move one of the displays +to its own window so you can see both display devices side-by-side. + guest side -- -- 1.8.3.1
Re: [Qemu-devel] [PATCH 5/5] virtio-blk: Drop VirtIOBlockReq.read
On Tue, 06/03 15:37, Paolo Bonzini wrote: I guess this is more of an RFC, but still a useful starting point for discussion. Il 03/06/2014 14:52, Fam Zheng ha scritto: diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index e406efa..74f0f32 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -146,7 +146,6 @@ typedef struct VirtIOBlockReq { #ifdef CONFIG_VIRTIO_BLK_DATA_PLANE struct VirtIOBlockDataPlane *s; This is just dev-dataplane, so it's trivial to remove. QEMUIOVector *inhdr;/* iovecs for virtio_blk_inhdr */ This can be unified with the in field; the status is only one byte, so using a full-blown QEMUIOVector is overkill. Stefan, what do you think? For the sake of restarting requests, we also need dataplane to populate the out field for dataplane. We can also take the occasion to change it from struct virtio_blk_outhdr * to struct virtio_blk_outhdr for non-dataplane and use iov_discard_front on the elem (see dataplane's process_request function). Using pointer avoids copying, what's the advantage of converting to sturct virtio_blk_outhdr for non-dataplane code? For thread-safety? Fam Can you do it in v2 of this patch series? With this in place we can look at the missing pieces: - rerror/werror - accounting (trivial) - multiwrite (if desired). Thanks, Paolo -bool read; /* read or write? */ #endif } VirtIOBlockReq;
Re: [Qemu-devel] [PATCH] aio: fix qemu_bh_schedule() bh-ctx race condition
On Tue, Jun 03, 2014 at 02:52:40PM +0200, Stefan Priebe - Profihost AG wrote: Tested-by: Stefan Priebe s.pri...@profihost.ag Thanks!
Re: [Qemu-devel] [PATCH v1 06/16] target-arm: Add FAR_EL2 and 3
Edgar E. Iglesias writes: On Tue, Jun 03, 2014 at 11:22:51AM +0100, Alex Bennée wrote: Edgar E. Iglesias writes: Ahh my confusion from earlier is now clear. Perhaps the two commits should be merged? Hi, The point is to have a non-functional diff and then incrementally add the function to easy bisectability if something breaks. I don't have a very strong opinion though, so if people insist I can squash. Having each commit point be buildable and testable is certainly a worthwhile goal from a bisect point of view. But for a simple no-op diff (i.e. functionaly identical, just moving a few bits around) which will then get updated with functional changes there is an argument to squash the two together. I like this patch series because the individual patches are narrow in scope and not too big hence easier to review. I don't think squashing some of non-function + functional diffs together detracts from that nobel goal. As you say it's a judgement call. -- Alex Bennée
Re: [Qemu-devel] [PATCH 1/3] nbd: Handle fixed new-style clients.
On Mon, Jun 02, 2014 at 11:09:02PM +0100, Hani Benhabiles wrote: On Mon, Jun 02, 2014 at 02:32:06PM +0200, Stefan Hajnoczi wrote: On Sat, May 31, 2014 at 10:39:40PM +0100, Hani Benhabiles wrote: Signed-off-by: Hani Benhabiles h...@linux.com --- include/block/nbd.h | 6 ++ nbd.c | 12 +++- 2 files changed, 13 insertions(+), 5 deletions(-) No explanation or link to specification for this new flag field? What's different about a new-style client? With this flag is set, the server tells the client that it can send another option if the server got a request with an option it doesn't understand (instead of the server closing the connection.) Thus, the while(1) loop in 2/3. Great, please include this explanation in the commit description. The kernel in Documentation/blockdev/nbd.txt points to the NBD project for documentation. The proto documentation is in [1]. Shouldn't Qemu also do the same ? [1] https://github.com/yoe/nbd/blob/master/doc/proto.txt Please add the link as a comment to the top of nbd.c. Stefan
Re: [Qemu-devel] [PATCH v3 0/8] virtio-blk: use alias properties in transport devices
On Tue, Jun 03, 2014 at 05:11:23PM +0200, Cornelia Huck wrote: On Fri, 30 May 2014 13:17:41 +0200 Stefan Hajnoczi stefa...@redhat.com wrote: v3: * Split qdev_alias_all_properties() into its own patch [Peter Crosthwaite] * Do not dereference DEVICE_CLASS(class) inline [Peter Crosthwaite] v2: * Add qdev_alias_all_properties() instead of virtio-blk-specific function [Paolo] * Explain refcount handling in doc comment [Paolo] * Fix property duplicate typo [Peter Crosthwaite] * Add the same object or to clarify commit description [Igor] Thanks for the feedback on the RFC. This time around the alias property is implemented at the QOM property level instead of at the qdev property level. Note that this series only addresses virtio-blk. In later series we can convert virtio net, scsi, rng, and serial. The virtio transport/device split is broken as follows: 1. The virtio-blk device is never finalized because the transport devices (virtio-blk-pci and friends) leak the refcount. 2. If we fix the refcount leak then we double-free the 'serial' string property upon hot unplug since its char* is copied into the virtio-blk device which has an identical 'serial' qdev property. This series solves both of these problems as follows: 1. Introduce a QOM alias property that lets the transport device forward property accesses into the virtio device (the child). 2. Use alias properties in transport devices, instead of keeping a duplicate copy of the VirtIOBlkConf struct. 3. Fix the virtio-blk device refcount leak. It's now safe to do this since the double-free has been resolved. Tested that hotplug/hotunplug of virtio-blk-pci still works. FWIW: I gave your qom-alias-property branch a quick test on s390. virtio-ccw: seems to work fine, hotunplug of virtio-blk-ccw is still fine, and the virtio-blk memory leaks due to missing finalization that valgind complained about are gone. s390-virtio: still boots, but with x-data-plane=on we get the predictable segfault in virtio_blk_data_plane_start() since s390-virtio doesn't do notifiers. Maybe the dataplane code should do a quick check for existence of the notifier callback when it allocates the dataplane structure? Okay, good idea. Thanks! Stefan
[Qemu-devel] [PATCH v3 4/4] target-ppc: Add support for new nmi() CPU callback
This defines a nmi() callback for POWERPC CPU class so the nmi HMP/QMP command gets supported for POWERPC machines. This calls POWERPC_EXCP_RESET (vector 0x100) in the guest to deliver NMI. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- Changes: v3: * ppc_cpu_do_nmi() is exported from excp_helper.c instead of powerpc_excp() --- target-ppc/cpu-qom.h| 1 + target-ppc/excp_helper.c| 8 target-ppc/translate_init.c | 17 + 3 files changed, 26 insertions(+) diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h index 47dc8e6..fe7d602 100644 --- a/target-ppc/cpu-qom.h +++ b/target-ppc/cpu-qom.h @@ -119,6 +119,7 @@ int ppc64_cpu_write_elf64_qemunote(WriteCoreDumpFunction f, int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, void *opaque); #ifndef CONFIG_USER_ONLY +void ppc_cpu_do_nmi(CPUState *cs); extern const struct VMStateDescription vmstate_ppc_cpu; #endif diff --git a/target-ppc/excp_helper.c b/target-ppc/excp_helper.c index a0c9fdc..11c23e7 100644 --- a/target-ppc/excp_helper.c +++ b/target-ppc/excp_helper.c @@ -801,6 +801,14 @@ void ppc_hw_interrupt(CPUPPCState *env) } } } + +void ppc_cpu_do_nmi(CPUState *cs) +{ +PowerPCCPU *cpu = POWERPC_CPU(cs); +CPUPPCState *env = cpu-env; + +powerpc_excp(cpu, env-excp_model, POWERPC_EXCP_RESET); +} #endif /* !CONFIG_USER_ONLY */ #if defined(DEBUG_OP) diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 4d94015..fd24be5 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -8510,6 +8510,22 @@ static void ppc_cpu_initfn(Object *obj) } } +#ifndef CONFIG_USER_ONLY +static void ppc_cpu_do_nmi_on_cpu(void *arg) +{ +CPUState *cs = arg; + +cpu_synchronize_state(cs); +ppc_cpu_do_nmi(cs); +} + +static int ppc_cpu_nmi(CPUState *cs) +{ +async_run_on_cpu(cs, ppc_cpu_do_nmi_on_cpu, cs); +return 0; +} +#endif + static void ppc_cpu_class_init(ObjectClass *oc, void *data) { PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); @@ -8536,6 +8552,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) #ifdef CONFIG_USER_ONLY cc-handle_mmu_fault = ppc_cpu_handle_mmu_fault; #else +cc-nmi = ppc_cpu_nmi; cc-get_phys_page_debug = ppc_cpu_get_phys_page_debug; cc-vmsd = vmstate_ppc_cpu; #if defined(TARGET_PPC64) -- 2.0.0
[Qemu-devel] [PATCH v3 3/4] target-i386: Migrate to new nmi() CPU callback
This defines a nmi() callback for i386 CPU class. This removes #ifdef I386 branch in qmp_inject_nmi so new i386's nmi() callback is going to be used for NMI. This changes code to inject NMI on the current CPU instead of injecting it on every CPU. However that does not seem to be an issue. Since kvm_apic_external_nmi() takes care of preforming operations in the specific CPU thread so no extra measure is required here. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- Changes: v3: * now contains both old code removal and new code insertion, easier to track changes * fixed compile for linux-user --- cpus.c| 14 -- target-i386/cpu.c | 16 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/cpus.c b/cpus.c index 83223d3..c0c8ac9 100644 --- a/cpus.c +++ b/cpus.c @@ -1468,19 +1468,6 @@ exit: void qmp_inject_nmi(Error **errp) { -#if defined(TARGET_I386) -CPUState *cs; - -CPU_FOREACH(cs) { -X86CPU *cpu = X86_CPU(cs); - -if (!cpu-apic_state) { -cpu_interrupt(cs, CPU_INTERRUPT_NMI); -} else { -apic_deliver_nmi(cpu-apic_state); -} -} -#else CPUState *cs = qemu_get_cpu(monitor_get_cpu_index()); CPUClass *cc = CPU_GET_CLASS(cs); int ret = -1; @@ -1491,5 +1478,4 @@ void qmp_inject_nmi(Error **errp) if (ret) { error_set(errp, QERR_UNSUPPORTED); } -#endif } diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 042a48d..af250a4 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2500,6 +2500,21 @@ static void x86_cpu_reset(CPUState *s) #endif } +static int x86_cpu_nmi(CPUState *cs) +{ +X86CPU *cpu = X86_CPU(cs); + +if (!cpu-apic_state) { +cpu_interrupt(cs, CPU_INTERRUPT_NMI); +#ifndef CONFIG_USER_ONLY +} else { +apic_deliver_nmi(cpu-apic_state); +#endif +} + +return 0; +} + #ifndef CONFIG_USER_ONLY bool cpu_is_bsp(X86CPU *cpu) { @@ -2808,6 +2823,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) xcc-parent_reset = cc-reset; cc-reset = x86_cpu_reset; +cc-nmi = x86_cpu_nmi; cc-reset_dump_flags = CPU_DUMP_FPU | CPU_DUMP_CCOP; cc-class_by_name = x86_cpu_class_by_name; -- 2.0.0
[Qemu-devel] [PATCH v3 1/4] cpus: Define NMI callback
This introduces an NMI (non maskable interrupt) callback per CPU class which QMP's nmi command may use to issue NMI on a CPU. This adds support for it in qmp_inject_nmi(). Since no architecture supports it at the moment, there is no change in behaviour. This changes inject-nmi command description for HMP and QMP. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- Changes: v3: * actual nmi() enablement moved from last patch to first patch * changed description for QMP command too --- cpus.c| 11 ++- hmp-commands.hx | 6 ++ include/qom/cpu.h | 1 + qapi-schema.json | 4 +--- qmp-commands.hx | 3 +-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/cpus.c b/cpus.c index dd7ac13..a000bd8 100644 --- a/cpus.c +++ b/cpus.c @@ -1495,6 +1495,15 @@ void qmp_inject_nmi(Error **errp) } } #else -error_set(errp, QERR_UNSUPPORTED); +CPUState *cs = qemu_get_cpu(monitor_get_cpu_index()); +CPUClass *cc = CPU_GET_CLASS(cs); +int ret = -1; + +if (cs cc-nmi) { +ret = cc-nmi(cs); +} +if (ret) { +error_set(errp, QERR_UNSUPPORTED); +} #endif } diff --git a/hmp-commands.hx b/hmp-commands.hx index 2e462c0..e97b5ec 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -830,19 +830,17 @@ The values that can be specified here depend on the machine type, but are the same that can be specified in the @code{-boot} command line option. ETEXI -#if defined(TARGET_I386) || defined(TARGET_S390X) { .name = nmi, .args_type = , .params = , -.help = inject an NMI on all guest's CPUs, +.help = inject an NMI on the given guest's CPU, .mhandler.cmd = hmp_inject_nmi, }, -#endif STEXI @item nmi @var{cpu} @findex nmi -Inject an NMI (x86) or RESTART (s390x) on the given CPU. +Inject an NMI on the given CPU. ETEXI diff --git a/include/qom/cpu.h b/include/qom/cpu.h index df977c8..b34f23b 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -108,6 +108,7 @@ typedef struct CPUClass { void (*parse_features)(CPUState *cpu, char *str, Error **errp); void (*reset)(CPUState *cpu); +int (*nmi)(CPUState *cs); int reset_dump_flags; bool (*has_work)(CPUState *cpu); void (*do_interrupt)(CPUState *cpu); diff --git a/qapi-schema.json b/qapi-schema.json index 7bc33ea..dcf6642 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1748,13 +1748,11 @@ ## # @inject-nmi: # -# Injects an Non-Maskable Interrupt into all guest's VCPUs. +# Injects an Non-Maskable Interrupt into the given guest's VCPU. # # Returns: If successful, nothing # # Since: 0.14.0 -# -# Notes: Only x86 Virtual Machines support this command. ## { 'command': 'inject-nmi' } diff --git a/qmp-commands.hx b/qmp-commands.hx index d8aa4ed..553375b 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -477,7 +477,7 @@ SQMP inject-nmi -- -Inject an NMI on guest's CPUs. +Inject an NMI on the given guest's CPU. Arguments: None. @@ -487,7 +487,6 @@ Example: - { return: {} } Note: inject-nmi fails when the guest doesn't support injecting. - Currently, only x86 (NMI) and s390x (RESTART) guests do. EQMP -- 2.0.0
Re: [Qemu-devel] [PATCH 1/1] dataplane: bail out on unsupported transport
On Tue, Jun 03, 2014 at 05:31:06PM +0200, Cornelia Huck wrote: If the virtio transport does not support notifiers (like s390-virtio), we can't use dataplane. Bail out early and let the user know what is wrong. Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com --- hw/block/dataplane/virtio-blk.c | 10 ++ 1 file changed, 10 insertions(+) Thanks! Reviewed-by: Stefan Hajnoczi stefa...@redhat.com
[Qemu-devel] [PATCH v3 2/4] target-s390x: Migrate to new nmi() CPU callback
This defines a nmi() callback for s390 CPU class. This removes #ifdef s390 branch in qmp_inject_nmi so new s390's nmi() callback is going to be used for NMI. Since nmi()-calling code is platform independent, CPUState::cpu_index is used instead of S390CPU::env.cpu_num. There should not be any change in behaviour as both @cpu_index and @cpu_num are global CPU numbers. Also, s390_cpu_restart() takes care of preforming operations in the specific CPU thread so no extra measure is required here either. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- Changes: v3: * now contains both old code removal and new code insertion, easier to track changes --- Is there any good reason to have @cpu_num in addition to @cpu_index? Just asking :) --- cpus.c | 14 -- target-s390x/cpu.c | 6 ++ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/cpus.c b/cpus.c index a000bd8..83223d3 100644 --- a/cpus.c +++ b/cpus.c @@ -1480,20 +1480,6 @@ void qmp_inject_nmi(Error **errp) apic_deliver_nmi(cpu-apic_state); } } -#elif defined(TARGET_S390X) -CPUState *cs; -S390CPU *cpu; - -CPU_FOREACH(cs) { -cpu = S390_CPU(cs); -if (cpu-env.cpu_num == monitor_get_cpu_index()) { -if (s390_cpu_restart(S390_CPU(cs)) == -1) { -error_set(errp, QERR_UNSUPPORTED); -return; -} -break; -} -} #else CPUState *cs = qemu_get_cpu(monitor_get_cpu_index()); CPUClass *cc = CPU_GET_CLASS(cs); diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index c3082b7..2d50f80 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -160,6 +160,11 @@ static void s390_cpu_full_reset(CPUState *s) tlb_flush(s, 1); } +static int s390_cpu_nmi(CPUState *cs) +{ +return s390_cpu_restart(S390_CPU(cs)); +} + #if !defined(CONFIG_USER_ONLY) static void s390_cpu_machine_reset_cb(void *opaque) { @@ -245,6 +250,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) scc-cpu_reset = s390_cpu_reset; scc-initial_cpu_reset = s390_cpu_initial_reset; cc-reset = s390_cpu_full_reset; +cc-nmi = s390_cpu_nmi; cc-has_work = s390_cpu_has_work; cc-do_interrupt = s390_cpu_do_interrupt; cc-dump_state = s390_cpu_dump_state; -- 2.0.0
[Qemu-devel] [PATCH v3 0/4] cpus: Add generic NMI support
This adds an NMI handler per CPUs. x86, s390 and ppc CPUS are supported. The change to existing behaviour is that x86 only delivers NMI to the current monitored CPU now, not to every CPU. Please comment. Thanks. Changes: v3: * patches reorganized * comments from v2 addressed, more details are in individual commit logs v2: * moved from machine interface to CPUClass callback * s390 and x86 moved to target-s390/target-i386 * x86 handler delivers to the current CPU only now Alexey Kardashevskiy (4): cpus: Define NMI callback target-s390x: Migrate to new nmi() CPU callback target-i386: Migrate to new nmi() CPU callback target-ppc: Add support for new nmi() CPU callback cpus.c | 33 +++-- hmp-commands.hx | 6 ++ include/qom/cpu.h | 1 + qapi-schema.json| 4 +--- qmp-commands.hx | 3 +-- target-i386/cpu.c | 16 target-ppc/cpu-qom.h| 1 + target-ppc/excp_helper.c| 8 target-ppc/translate_init.c | 17 + target-s390x/cpu.c | 6 ++ 10 files changed, 60 insertions(+), 35 deletions(-) -- 2.0.0
Re: [Qemu-devel] [PATCH] migration: Increase default max_downtime from 30ms to 300ms
On 05/05/2014 09:20 PM, Juan Quintela wrote: Alexey Kardashevskiy a...@ozlabs.ru wrote: On 04/13/2014 12:38 AM, Alexey Kardashevskiy wrote: On 03/27/2014 08:01 PM, Markus Armbruster wrote: Adding Juan. Ping? Patch is OK for me. Who else needs to be ok to get this in upstream? :) Thanks! As sender says, with guests doing anything/bigger than 1GB RAM is basically implosible to get into the 30ms downtime. Later, Juan. Ping? Alexey Kardashevskiy a...@ozlabs.ru writes: The existing timeout is 30ms which on 100MB/s (1Gbit) gives us 3MB/s rate maximum. If we put some load on the guest, it is easy to get page dirtying rate too big so live migration will never complete. In the case of libvirt that means that the guest will be stopped anyway after a timeout specified in the virsh migrate command and this normally generates even bigger delay. This changes max_downtime to 300ms which seems to be more reasonable value. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- migration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration.c b/migration.c index e0e24d4..02bbce9 100644 --- a/migration.c +++ b/migration.c @@ -144,7 +144,7 @@ void process_incoming_migration(QEMUFile *f) * the choice of nanoseconds is because it is the maximum resolution that * get_clock() can achieve. It is an internal measure. All user-visible * units must be in seconds */ -static uint64_t max_downtime = 3000; +static uint64_t max_downtime = 3; uint64_t migrate_max_downtime(void) { -- Alexey
Re: [Qemu-devel] [PATCH v2 5/6] qemu-bridge-helper: Fix fd leak in main()
On Wed, May 28, 2014 at 09:21:39PM +0800, arei.gong...@huawei.com wrote: From: Gonglei arei.gong...@huawei.com initialize fd and ctlfd, and close them at the end Signed-off-by: Gonglei arei.gong...@huawei.com --- qemu-bridge-helper.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) Reviewed-by: Stefan Hajnoczi stefa...@redhat.com
Re: [Qemu-devel] [PATCH-trivial] arch_init.c: Free 'cache' in cache_fini() to avoid memory leak
Chen Gang gang.chen.5...@gmail.com writes: Call g_free() after cache_fini() in migration_end(), but do not call g_free() after call cache_fini() in xbzrle_cache_resize() which will cause memory leak. cache_init() and cache_fini() are pair, so need let cache_fini() call g_free(cache) to match cache_init(), then fix current issue too. I'm not sure I get you. Is the following accurate? migration: Plug memory leak in migrate-set-cache-size command We call g_free() after cache_fini() in migration_end(), but we don't call it after cache_fini() in xbzrle_cache_resize(), leaking the memory. cache_init() and cache_fini() are a pair. Since cache_init() allocates the cache, let cache_fini() free it. This plugs the leak.
Re: [Qemu-devel] [Bug 1324112] [NEW] qemu parallel building error on libcacard.la
On Wed, May 28, 2014 at 12:52:10PM -, tal zilcer wrote: im building qemu with a large make -j value(9). sometimes the build fails because of an error: libtool: link: ar cru .libs/libcacard.a stubs/arch-query-cpu-def.o stubs/clock-warp.o stubs/cpu-get-clock.o stubs/cpu-get-icount.o stubs/dump.o stubs/fdset-add-fd.o stubs/fdset-find-fd.o stubs/fdset-get-fd.o stubs/fdset-remove-fd.o stubs/gdbstub.o stubs/get-fd.o stubs/get-vm-name.o stubs/iothread-lock.o stubs/migr-blocker.o stubs/mon-is-qmp.o stubs/mon-printf.o stubs/mon-print-filename.o stubs/mon-protocol-event.o stubs/mon-set-error.o stubs/pci-drive-hot-add.o stubs/qtest.o stubs/reset.o stubs/runstate-check.o stubs/set-fd-handler.o stubs/slirp.o stubs/sysbus.o stubs/uuid.o stubs/vm-stop.o stubs/vmstate.o stubs/cpus.o stubs/kvm.o libcacard/cac.o libcacard/event.o libcacard/vcard.o libcacard/vreader.o libcacard/vcard_emul_nss.o libcacard/vcard_emul_type.o libcacard/card_7816.o libcacard/vcardt.o util/osdep.o util/cutils.o util/qemu-timer-common.o util/error.o util/qemu-error.o util/oslib-posix.o util/qemu-thread-posix.o trace/generated-events.o trace/default.o trace/control.o trace/generated-tracers.o ar: trace/generated-events.o: No such file or directory make[2]: *** [libcacard.la] Error 1 i see the build of generated-events.o in the log before the ar command. because of the -j it was probably not completed yet. the generated-events.o build command: /usr/bin/gcc -I/home/npsdb/qemu/qemu/tcg -I/home/npsdb/qemu/qemu/tcg/i386 -I/home/npsdb/qemu/qemu/linux-headers -I/home/npsdb/qemu/build/linux_x86_64/linux-headers -I. -I/home/npsdb/qemu/qemu -I/home/npsdb/jenkins/qemu/qemu/include -I/home/npsdb/qemu/qemu/libcacard -Itrace -Itrace -fPIE -DPIE -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-all -I/usr/include/libpng12 -I/usr/include/nss3 -I/usr/include/nspr4 -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/home/npsdb/qemu/qemu/tests -I qga/qapi-generated -MMD -MP -MT trace/generated-events.o -MF trace/generated-events.d -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -g -c -o trace/generated-events.o trace/generated-events.c must be a race condition in the makefile because of a missing dependency. i tried to find it but it was a little bit complicated to me. Which QEMU version are you building? In qemu.git/master I can see the dependency on trace/* in libcacard/Makefile. Stefan
Re: [Qemu-devel] [PATCH-trivial] arch_init.c: Always be sure that 'encoded_buf' and 'current_buf' are lock protected
Chen Gang gang.chen.5...@gmail.com writes: 'encoded_buf' and 'current_buf' are lock protected during using in save_xbzrle_page() in ram_save_page(), and during freeing in migration_end(). So recommend to let them lock protected during starting, just like we have done to 'cache'. I'd recommend against routing locking patches through -trivial. The code has maintainers, and you cc'ed them.
Re: [Qemu-devel] [PATCH qom v1 1/1] qom: object: remove parent pointer when unparenting
On Mon, Jun 02, 2014 at 10:35:30AM +1000, Peter Crosthwaite wrote: Ping! Andreas seems to be offline (vacation?). I'm sure he'll see this when he gets back. Stefan
Re: [Qemu-devel] [PATCH 1/1] Makefile: Correct path in stripping tool binaries
On 4 June 2014 02:37, Sam Bobroff sam.bobr...@au1.ibm.com wrote: Allow make install to handle tool binaries that reside in sub-directories. Without this patch make install will fail if it needs to strip a tool binary (e.g. debugging is not enabled) that is installed from a subdirectory. An example is fsdev/virtfs-proxy-helper. Signed-off-by: Sam Bobroff sam.bobr...@au1.ibm.com --- Makefile |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d830483..9c23265 100644 --- a/Makefile +++ b/Makefile @@ -380,7 +380,7 @@ install-datadir install-localstatedir ifneq ($(TOOLS),) $(INSTALL_PROG) $(TOOLS) $(DESTDIR)$(bindir) ifneq ($(STRIP),) - $(STRIP) $(TOOLS:%=$(DESTDIR)$(bindir)/%) + $(STRIP) $(foreach T,$(TOOLS),$(DESTDIR)$(bindir)/$(notdir $T)) endif endif ifneq ($(CONFIG_MODULES),) -- 1.7.10.4 We should probably also do this on the other invocation of $(STRIP} for installs into libexecdir. thanks -- PMM
Re: [Qemu-devel] [PATCH] block: asynchronously stop the VM on I/O errors
Am 03.06.2014 um 17:51 hat Paolo Bonzini geschrieben: Il 03/06/2014 16:37, Kevin Wolf ha scritto: Am 03.06.2014 um 16:16 hat Paolo Bonzini geschrieben: With virtio-blk dataplane, I/O errors might occur while QEMU is not in the main I/O thread. However, it's invalid to call vm_stop when we're neither in a VCPU thread nor in the main I/O thread, even if we were to take the iothread mutex around it. To avoid this problem, simply raise a request to the main I/O thread, similar to what QEMU does when vm_stop is called from a CPU thread. We know that bdrv_error_action is called from an AIO callback, and the moment at which the callback will fire is not well-defined; it depends on the moment at which the disk or OS finishes the operation, which can happen at any time. Note that QEMU is certainly not in a CPU thread and we do not need to call cpu_stop_current() like vm_stop() does. Do I understand correctly that this is not a fundamental truth of qemu's operation, but holds true only because the drivers that do support rerror/werror all use bdrv_aio_readv/writev(), which guarantees that a BH is used in error cases? Otherwise I think an I/O handler in a vcpu thread could directly call into the block layer and fail immediately (might happen for example if we added rerror/werror support to ATAPI). By delaying the actual state change, does this break the invariant that bs-iostatus is BLOCK_DEVICE_IO_STATUS_OK while the VM is running? These two comments are actually related, in that the invariant was already not respected if an I/O handler in a VCPU thread could fail immediately. Oh, right, I somehow expected that vm_stop() waits for the CPU to be stopped before it returns, but that's not what it does. Breaking this invariant means that you have a very small window where {'execute':'cont'} would actually not restart the VM. I think this should be fixed by dropping the request in vm_start, like this: [...] Sounds like an option. Do we need to send a QEVENT_STOP/QEVENT_RESUME pair? If we don't, the client will still notice a difference to a real stop and resume. Also, I think that bdrv_emit_qmp_error_event is placed wrong. It should be called only after setting the iostatus, otherwise there is a small window where the iostatus is no error but the event has been generated already. Yes, I agree. The documentation for this event actually answers my above question: Note: If action is stop, a STOP event will eventually follow the BLOCK_IO_ERROR event. Perhaps we should also change the documentation of the stop value to clarify that the VM may not actually be stopped yet. It currently reads like this: stop: error caused VM to be stopped Kevin
Re: [Qemu-devel] [PATCH v2 4/8] linux-user: arm: handle CPSR.E correctly in strex emulation
On 4 June 2014 08:48, Paolo Bonzini pbonz...@redhat.com wrote: Il 03/06/2014 11:54, Peter Maydell ha scritto: In system emulation it's clear how we should implement things: TARGET_WORDS_BIGENDIAN is never set, data accesses honour CPSR.E by doing MO_BE or MO_LE accesses, instruction accesses are always MO_LE, and SCTLR.B is implemented by XORing the address with 3 (for byte accesses) or 1 (for halfword accesses). I think it's 2 for halfword accesses. :) Doh :-) What about 64-bit accesses? Does the processor swap the two words of the result? Yes. (There's a helpful table describing this in section O.3.2 (in Appendix O) of the v7 ARM ARM.) thanks -- PMM
[Qemu-devel] [PATCH v3 09/10] usb: tag usb host controller as hotpluggable
From: Gonglei arei.gong...@huawei.com usb host controller should be able to support hotplug/unplug, as the same as the other pci devices, which not enable multifunction capability. BTW, the qemu have not the capability to support hotplug mulitfuncition pci devices at present. Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/hcd-ehci-pci.c | 1 - hw/usb/hcd-ohci.c | 1 - hw/usb/hcd-uhci.c | 1 - hw/usb/hcd-xhci.c | 1 - 4 files changed, 4 deletions(-) diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c index 289ca3b..612aab1 100644 --- a/hw/usb/hcd-ehci-pci.c +++ b/hw/usb/hcd-ehci-pci.c @@ -137,7 +137,6 @@ static void ehci_class_init(ObjectClass *klass, void *data) k-exit = usb_ehci_pci_exit; k-class_id = PCI_CLASS_SERIAL_USB; k-config_write = usb_ehci_pci_write_config; -dc-hotpluggable = false; dc-vmsd = vmstate_ehci_pci; dc-props = ehci_pci_properties; } diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index b513a13..5dfcb6f 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -2121,7 +2121,6 @@ static void ohci_pci_class_init(ObjectClass *klass, void *data) set_bit(DEVICE_CATEGORY_USB, dc-categories); dc-desc = Apple USB Controller; dc-props = ohci_pci_properties; -dc-hotpluggable = false; dc-vmsd = vmstate_ohci; } diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 4e8a640..0ecb56d 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -1300,7 +1300,6 @@ static void uhci_class_init(ObjectClass *klass, void *data) k-device_id = info-device_id; k-revision = info-revision; k-class_id = PCI_CLASS_SERIAL_USB; -dc-hotpluggable = false; dc-vmsd = vmstate_uhci; dc-props = uhci_properties; set_bit(DEVICE_CATEGORY_USB, dc-categories); diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 85ff5d0..bc7cd04 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -3877,7 +3877,6 @@ static void xhci_class_init(ObjectClass *klass, void *data) dc-vmsd= vmstate_xhci; dc-props = xhci_properties; dc-reset = xhci_reset; -dc-hotpluggable = false; set_bit(DEVICE_CATEGORY_USB, dc-categories); k-init = usb_xhci_initfn; k-exit = usb_xhci_exit; -- 1.7.12.4
[Qemu-devel] [PATCH v3 03/10] usb-ohci: add exit function
From: Gonglei arei.gong...@huawei.com clean up ohci resource when ohci pci device exit. Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/hcd-ohci.c | 21 + 1 file changed, 21 insertions(+) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index dc1adbf..b513a13 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -1954,6 +1954,26 @@ static int usb_ohci_initfn_pci(PCIDevice *dev) return 0; } +static void usb_ohci_exit(PCIDevice *dev) +{ +OHCIPCIState *ohci = PCI_OHCI(dev); +OHCIState *s = ohci-state; + +ohci_bus_stop(s); + +if (s-async_td) { +usb_cancel_packet(s-usb_packet); +s-async_td = 0; +} +ohci_stop_endpoints(s); + +memory_region_destroy(s-mem); + +if (!ohci-masterbus) { +usb_bus_release(s-bus); +} +} + #define TYPE_SYSBUS_OHCI sysbus-ohci #define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj), TYPE_SYSBUS_OHCI) @@ -2094,6 +2114,7 @@ static void ohci_pci_class_init(ObjectClass *klass, void *data) PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k-init = usb_ohci_initfn_pci; +k-exit = usb_ohci_exit; k-vendor_id = PCI_VENDOR_ID_APPLE; k-device_id = PCI_DEVICE_ID_APPLE_IPID_USB; k-class_id = PCI_CLASS_SERIAL_USB; -- 1.7.12.4
[Qemu-devel] [PATCH v3 06/10] usb-ehci: add ehci unrealize funciton
From: Gonglei arei.gong...@huawei.com cleanup ehci controller resource, both pci and sysbus if they're necessary. Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/hcd-ehci.c | 29 + hw/usb/hcd-ehci.h | 1 + 2 files changed, 30 insertions(+) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 76e939d..172ca04 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -2471,6 +2471,35 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp) s-vmstate = qemu_add_vm_change_state_handler(usb_ehci_vm_state_change, s); } +void usb_ehci_unrealize(EHCIState *s, DeviceState *dev, Error **errp) +{ +if (s-frame_timer) { +timer_del(s-frame_timer); +timer_free(s-frame_timer); +s-frame_timer = NULL; +} +if (s-async_bh) { +qemu_bh_delete(s-async_bh); +} + +ehci_queues_rip_all(s, 0); +ehci_queues_rip_all(s, 1); + +memory_region_del_subregion(s-mem, s-mem_caps); +memory_region_del_subregion(s-mem, s-mem_opreg); +memory_region_del_subregion(s-mem, s-mem_ports); +memory_region_destroy(s-mem_caps); +memory_region_destroy(s-mem_opreg); +memory_region_destroy(s-mem_ports); +memory_region_destroy(s-mem); + +usb_bus_release(s-bus); + +if (s-vmstate) { +qemu_del_vm_change_state_handler(s-vmstate); +} +} + void usb_ehci_init(EHCIState *s, DeviceState *dev) { /* 2.2 host controller interface version */ diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h index 594d9d3..4858b7e 100644 --- a/hw/usb/hcd-ehci.h +++ b/hw/usb/hcd-ehci.h @@ -323,6 +323,7 @@ extern const VMStateDescription vmstate_ehci; void usb_ehci_init(EHCIState *s, DeviceState *dev); void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp); +void usb_ehci_unrealize(EHCIState *s, DeviceState *dev, Error **errp); #define TYPE_PCI_EHCI pci-ehci-usb #define PCI_EHCI(obj) OBJECT_CHECK(EHCIPCIState, (obj), TYPE_PCI_EHCI) -- 1.7.12.4
[Qemu-devel] [PATCH v3 07/10] usb-ehci: add ehci-pci device exit function
From: Gonglei arei.gong...@huawei.com clean up ehci resource when ehci pci device exit. Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/hcd-ehci-pci.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c index 505741a..289ca3b 100644 --- a/hw/usb/hcd-ehci-pci.c +++ b/hw/usb/hcd-ehci-pci.c @@ -84,6 +84,19 @@ static void usb_ehci_pci_init(Object *obj) usb_ehci_init(s, DEVICE(obj)); } +static void usb_ehci_pci_exit(PCIDevice *dev) +{ +EHCIPCIState *i = PCI_EHCI(dev); +EHCIState *s = i-ehci; + +usb_ehci_unrealize(s, DEVICE(dev), NULL); + +if (s-irq) { +g_free(s-irq); +s-irq = NULL; +} +} + static void usb_ehci_pci_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int l) { @@ -121,6 +134,7 @@ static void ehci_class_init(ObjectClass *klass, void *data) PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k-init = usb_ehci_pci_initfn; +k-exit = usb_ehci_pci_exit; k-class_id = PCI_CLASS_SERIAL_USB; k-config_write = usb_ehci_pci_write_config; dc-hotpluggable = false; -- 1.7.12.4
[Qemu-devel] [PATCH v3 01/10] usb: add usb_bus_release function
From: Gonglei arei.gong...@huawei.com add global variables releasing logic when the usb buses were removed or hot-unpluged. Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/bus.c | 7 +++ include/hw/usb.h | 1 + 2 files changed, 8 insertions(+) diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 927a47b..84e8bb4 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -87,6 +87,13 @@ void usb_bus_new(USBBus *bus, size_t bus_size, QTAILQ_INSERT_TAIL(busses, bus, next); } +void usb_bus_release(USBBus *bus) +{ +assert(next_usb_bus 0); + +QTAILQ_REMOVE(busses, bus, next); +} + USBBus *usb_bus_find(int busnr) { USBBus *bus; diff --git a/include/hw/usb.h b/include/hw/usb.h index 8bcab48..0ddc29c 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -524,6 +524,7 @@ struct USBBusOps { void usb_bus_new(USBBus *bus, size_t bus_size, USBBusOps *ops, DeviceState *host); +void usb_bus_release(USBBus *bus); USBBus *usb_bus_find(int busnr); void usb_legacy_register(const char *typename, const char *usbdevice_name, USBDevice *(*usbdevice_init)(USBBus *bus, -- 1.7.12.4
[Qemu-devel] [PATCH v3 10/10] usb: add usb host adapters exit trace
From: Gonglei arei.gong...@huawei.com Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/hcd-ehci.c | 2 ++ hw/usb/hcd-uhci.c | 2 ++ hw/usb/hcd-xhci.c | 2 ++ trace-events | 3 +++ 4 files changed, 9 insertions(+) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 172ca04..8211aea 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -2473,6 +2473,8 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp) void usb_ehci_unrealize(EHCIState *s, DeviceState *dev, Error **errp) { +trace_usb_ehci_unrealize(); + if (s-frame_timer) { timer_del(s-frame_timer); timer_free(s-frame_timer); diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 0ecb56d..665e380 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -1260,6 +1260,8 @@ static void usb_uhci_exit(PCIDevice *dev) { UHCIState *s = DO_UPCAST(UHCIState, dev, dev); +trace_usb_uhci_exit(); + if (s-frame_timer) { timer_del(s-frame_timer); timer_free(s-frame_timer); diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index bc7cd04..86d9389 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -3649,6 +3649,8 @@ static void usb_xhci_exit(PCIDevice *dev) int i; XHCIState *xhci = XHCI(dev); +trace_usb_xhci_exit(); + for (i = 0; i xhci-numslots; i++) { xhci_disable_slot(xhci, i + 1); } diff --git a/trace-events b/trace-events index ffe6e62..1e03707 100644 --- a/trace-events +++ b/trace-events @@ -292,6 +292,7 @@ usb_port_release(int bus, const char *port) bus %d, port %s # hw/usb/hcd-ehci.c usb_ehci_reset(void) === RESET === +usb_ehci_unrealize(void) === UNREALIZE === usb_ehci_opreg_read(uint32_t addr, const char *str, uint32_t val) rd mmio %04x [%s] = %x usb_ehci_opreg_write(uint32_t addr, const char *str, uint32_t val) wr mmio %04x [%s] = %x usb_ehci_opreg_change(uint32_t addr, const char *str, uint32_t new, uint32_t old) ch mmio %04x [%s] = %x (old: %x) @@ -324,6 +325,7 @@ usb_ehci_dma_error(void) # hw/usb/hcd-uhci.c usb_uhci_reset(void) === RESET === +usb_uhci_exit(void) === EXIT === usb_uhci_schedule_start(void) usb_uhci_schedule_stop(void) usb_uhci_frame_start(uint32_t num) nr %d @@ -353,6 +355,7 @@ usb_uhci_td_complete(uint32_t qh, uint32_t td) qh 0x%x, td 0x%x # hw/usb/hcd-xhci.c usb_xhci_reset(void) === RESET === +usb_xhci_exit(void) === EXIT === usb_xhci_run(void) usb_xhci_stop(void) usb_xhci_cap_read(uint32_t off, uint32_t val) off 0x%04x, ret 0x%08x -- 1.7.12.4
[Qemu-devel] [PATCH v3 05/10] usb-ehci: add vmstate properity for EHCIState
From: Gonglei arei.gong...@huawei.com since hotunplug the ehci host adapter, we should delete vm_change_state_handler also, so the VMChangeStateEntry should be saved in EHCIState. Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/hcd-ehci.c | 2 +- hw/usb/hcd-ehci.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index a00a93c..76e939d 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -2468,7 +2468,7 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp) s-device = dev; qemu_register_reset(ehci_reset, s); -qemu_add_vm_change_state_handler(usb_ehci_vm_state_change, s); +s-vmstate = qemu_add_vm_change_state_handler(usb_ehci_vm_state_change, s); } void usb_ehci_init(EHCIState *s, DeviceState *dev) diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h index 1ad4b96..594d9d3 100644 --- a/hw/usb/hcd-ehci.h +++ b/hw/usb/hcd-ehci.h @@ -316,6 +316,7 @@ struct EHCIState { uint32_t async_stepdown; uint32_t periodic_sched_active; bool int_req_by_async; +VMChangeStateEntry *vmstate; }; extern const VMStateDescription vmstate_ehci; -- 1.7.12.4
[Qemu-devel] [PATCH v3 02/10] usb-ohci: Fix memory leak for ohci timer
From: Gonglei arei.gong...@huawei.com Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/hcd-ohci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index cd87074..dc1adbf 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -1371,8 +1371,10 @@ static int ohci_bus_start(OHCIState *ohci) /* Stop sending SOF tokens on the bus */ static void ohci_bus_stop(OHCIState *ohci) { -if (ohci-eof_timer) +if (ohci-eof_timer) { timer_del(ohci-eof_timer); +timer_free(ohci-eof_timer); +} ohci-eof_timer = NULL; } -- 1.7.12.4
[Qemu-devel] [PATCH v3 00/10] usb: usb host adapter hotplug
From: Gonglei arei.gong...@huawei.com add support for usb host adapter hotplug, as the same as other pci devices. change since v2: * add ehci unrealize function suggested by Gerd. * add usb host adapters exit trace. * rebase on latest qemu master tree. changes since v1: * rework usb_bus_release function suggested by Gerd. * add more completely resource cleanup for every usb host adapter. * fix memory leak. Gonglei (10): usb: add usb_bus_release function usb-ohci: Fix memory leak for ohci timer usb-ohci: add exit function usb-uhci: clean up uhci resource when pci-uhci exit usb-ehci: add vmstate properity for EHCIState usb-ehci: add ehci unrealize funciton usb-ehci: add ehci-pci device exit function usb-xhci: add exit function usb: tag usb host controller as hotpluggable usb: add usb host adapters exit trace hw/usb/bus.c | 7 +++ hw/usb/hcd-ehci-pci.c | 15 ++- hw/usb/hcd-ehci.c | 33 - hw/usb/hcd-ehci.h | 2 ++ hw/usb/hcd-ohci.c | 26 -- hw/usb/hcd-uhci.c | 19 ++- hw/usb/hcd-xhci.c | 49 - include/hw/usb.h | 1 + trace-events | 3 +++ 9 files changed, 149 insertions(+), 6 deletions(-) -- 1.7.12.4
[Qemu-devel] [PATCH v3 04/10] usb-uhci: clean up uhci resource when pci-uhci exit
From: Gonglei arei.gong...@huawei.com clean up uhci resource when uhci pci device exit. Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/hcd-uhci.c | 16 1 file changed, 16 insertions(+) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index c3bf72c..4e8a640 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -1260,7 +1260,23 @@ static void usb_uhci_exit(PCIDevice *dev) { UHCIState *s = DO_UPCAST(UHCIState, dev, dev); +if (s-frame_timer) { +timer_del(s-frame_timer); +timer_free(s-frame_timer); +s-frame_timer = NULL; +} + +if (s-bh) { +qemu_bh_delete(s-bh); +} + +uhci_async_cancel_all(s); + memory_region_destroy(s-io_bar); + +if (!s-masterbus) { +usb_bus_release(s-bus); +} } static Property uhci_properties[] = { -- 1.7.12.4
Re: [Qemu-devel] [PATCH 4/4] s390x/kvm: hw debugging support via guest PER facility
On 30/05/14 11:01, Alexander Graf wrote: On 30.05.14 10:57, Christian Borntraeger wrote: On 30/05/14 10:32, Alexander Graf wrote: +case KVM_HW_BP: +if (find_hw_breakpoint(arch_info-addr, -1, arch_info-type)) { +ret = EXCP_DEBUG; +} +break; +case KVM_SINGLESTEP: +if (cs-singlestep_enabled) { +ret = EXCP_DEBUG; +} +break; +default: +ret = -ENOSYS; +} + +return ret; What happens to the diag 501 now? Are we safe to just drop it? There can only be a small number of HW breakpoints (basically only one from-to range on s390). So gdb can (and will) use both (hbreak vs. break) Ah, let me explain what I'm referring to here. On x86 (and PPC, though the patches are still missing), we use a generic breakpoint instruction for sw breakpoints. The specific breakpoint interrupt generated by that instruction traps into KVM which forwards it to QEMU. If QEMU now detects that it didn't put the breakpoint into place, it assumes that it's the guest that wanted the breakpoint to happen, so it deflects a breakpoint interrupt into the guest. My question here is whether we need something similar on s390x. With DIAG, I think we're safe, as the guest can't expect that one to do anything useful, but if we want to switch to a 2-byte breakpoint instruction instead, it might make sense to implement the deflection mechanism. Oh, I though What happens to the diag 501 now? Are we safe to just drop it? was a question if we can get rid of the code. Regarding deflection, yes if guest and host hardware breakpoints (PER) we need to handle that (The host kernel is doing that in filter_guest_per_event) With software breakpoints: yes diag501 is safe to use. When we change the instruction later on then we have to see if we need deflection (could be). Christian Hi Alex, I am already working on a solution for 2 byte software breakpoints. The solution will most likely look like what we have on x86: A generic breakpoint instruction (e.g. invalid opcode 0x0001) that is filtered in QEMU. We'll need kernel support to allow invalid instructions to be intercepted and handled in QEMU. I already have a prototype running. David
Re: [Qemu-devel] [PATCH 5/5] virtio-blk: Drop VirtIOBlockReq.read
Il 04/06/2014 09:53, Fam Zheng ha scritto: For the sake of restarting requests, we also need dataplane to populate the out field for dataplane. We can also take the occasion to change it from struct virtio_blk_outhdr * to struct virtio_blk_outhdr for non-dataplane and use iov_discard_front on the elem (see dataplane's process_request function). Using pointer avoids copying, what's the advantage of converting to sturct virtio_blk_outhdr for non-dataplane code? For thread-safety? The virtio code currently assumes that the outhdr is in its own iovec. This is not guaranteed by the spec, it's just that the drivers do it because QEMU required it. Paolo
Re: [Qemu-devel] [PATCH v27 07/33] QemuOpts: add qemu_opt_get_*_del functions for replace work
On Wed, May 07, 2014 at 05:58:32PM +0800, Chunyan Liu wrote: diff --git a/util/qemu-option.c b/util/qemu-option.c index 4d2d4d1..32e1d50 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -575,6 +575,19 @@ static void qemu_opt_del(QemuOpt *opt) g_free(opt); } +/* qemu_opt_set allows many settings for the same option. + * This function deletes all settings for an option. + */ +static void qemu_opt_del_all(QemuOpts *opts, const char *name) +{ +QemuOpt *opt, *next_opt; + +QTAILQ_FOREACH_SAFE(opt, opts-head, next, next_opt) { +if (!strcmp(opt-name, name)) +qemu_opt_del(opt); QEMU coding style always uses curlies, even when the if body is only one statement. Please use scripts/checkpatch.pl to scan your patches before they are sent. I can fix this up while merging. No need to resend.
Re: [Qemu-devel] [PATCH] block: asynchronously stop the VM on I/O errors
Il 04/06/2014 10:28, Kevin Wolf ha scritto: Breaking this invariant means that you have a very small window where {'execute':'cont'} would actually not restart the VM. I think this should be fixed by dropping the request in vm_start, like this: [...] Sounds like an option. Do we need to send a QEVENT_STOP/QEVENT_RESUME pair? If we don't, the client will still notice a difference to a real stop and resume. Yes, better do that. Also, I think that bdrv_emit_qmp_error_event is placed wrong. It should be called only after setting the iostatus, otherwise there is a small window where the iostatus is no error but the event has been generated already. Yes, I agree. The documentation for this event actually answers my above question: Note: If action is stop, a STOP event will eventually follow the BLOCK_IO_ERROR event. Perhaps we should also change the documentation of the stop value to clarify that the VM may not actually be stopped yet. It currently reads like this: stop: error caused VM to be stopped Yes. Paolo
Re: [Qemu-devel] [PATCH v3 0/4] cpus: Add generic NMI support
Il 04/06/2014 10:08, Alexey Kardashevskiy ha scritto: This adds an NMI handler per CPUs. x86, s390 and ppc CPUS are supported. The change to existing behaviour is that x86 only delivers NMI to the current monitored CPU now, not to every CPU. Please comment. Thanks. Changes: v3: * patches reorganized * comments from v2 addressed, more details are in individual commit logs v2: * moved from machine interface to CPUClass callback * s390 and x86 moved to target-s390/target-i386 * x86 handler delivers to the current CPU only now Alexey Kardashevskiy (4): cpus: Define NMI callback target-s390x: Migrate to new nmi() CPU callback target-i386: Migrate to new nmi() CPU callback target-ppc: Add support for new nmi() CPU callback cpus.c | 33 +++-- hmp-commands.hx | 6 ++ include/qom/cpu.h | 1 + qapi-schema.json| 4 +--- qmp-commands.hx | 3 +-- target-i386/cpu.c | 16 target-ppc/cpu-qom.h| 1 + target-ppc/excp_helper.c| 8 target-ppc/translate_init.c | 17 + target-s390x/cpu.c | 6 ++ 10 files changed, 60 insertions(+), 35 deletions(-) Acked-by: Paolo Bonzini pbonz...@redhat.com
[Qemu-devel] [PATCH v3 08/10] usb-xhci: add exit function
From: Gonglei arei.gong...@huawei.com clean up xhci resource when xhci pci device exit. Signed-off-by: Gonglei arei.gong...@huawei.com --- hw/usb/hcd-xhci.c | 46 ++ 1 file changed, 46 insertions(+) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 7f2af89..85ff5d0 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -3644,6 +3644,51 @@ static int usb_xhci_initfn(struct PCIDevice *dev) return 0; } +static void usb_xhci_exit(PCIDevice *dev) +{ +int i; +XHCIState *xhci = XHCI(dev); + +for (i = 0; i xhci-numslots; i++) { +xhci_disable_slot(xhci, i + 1); +} + +if (xhci-mfwrap_timer) { +timer_del(xhci-mfwrap_timer); +timer_free(xhci-mfwrap_timer); +xhci-mfwrap_timer = NULL; +} + +memory_region_del_subregion(xhci-mem, xhci-mem_cap); +memory_region_del_subregion(xhci-mem, xhci-mem_oper); +memory_region_del_subregion(xhci-mem, xhci-mem_runtime); +memory_region_del_subregion(xhci-mem, xhci-mem_doorbell); + +memory_region_destroy(xhci-mem_cap); +memory_region_destroy(xhci-mem_oper); +memory_region_destroy(xhci-mem_runtime); +memory_region_destroy(xhci-mem_doorbell); + +for (i = 0; i xhci-numports; i++) { +XHCIPort *port = xhci-ports[i]; +memory_region_del_subregion(xhci-mem, port-mem); +memory_region_destroy(port-mem); +} + +/* destroy msix memory region */ +if (dev-msix_table dev-msix_pba + dev-msix_entry_used) { +memory_region_del_subregion(xhci-mem, dev-msix_table_mmio); +memory_region_destroy(dev-msix_table_mmio); +memory_region_del_subregion(xhci-mem, dev-msix_pba_mmio); +memory_region_destroy(dev-msix_pba_mmio); +} + +memory_region_destroy(xhci-mem); + +usb_bus_release(xhci-bus); +} + static int usb_xhci_post_load(void *opaque, int version_id) { XHCIState *xhci = opaque; @@ -3835,6 +3880,7 @@ static void xhci_class_init(ObjectClass *klass, void *data) dc-hotpluggable = false; set_bit(DEVICE_CATEGORY_USB, dc-categories); k-init = usb_xhci_initfn; +k-exit = usb_xhci_exit; k-vendor_id= PCI_VENDOR_ID_NEC; k-device_id= PCI_DEVICE_ID_NEC_UPD720200; k-class_id = PCI_CLASS_SERIAL_USB; -- 1.7.12.4
Re: [Qemu-devel] [PATCH v3 0/4] cpus: Add generic NMI support
On 4 June 2014 09:08, Alexey Kardashevskiy a...@ozlabs.ru wrote: This adds an NMI handler per CPUs. x86, s390 and ppc CPUS are supported. The change to existing behaviour is that x86 only delivers NMI to the current monitored CPU now, not to every CPU. So this series means that the nmi command and handler does * NMI on x86 * reset on PPC * restart on S390 That doesn't seem generic at all, and suggests this should not be a common CPU method/callback. thanks -- PMM
Re: [Qemu-devel] [PATCH v27 00/33] replace QEMUOptionParameter with QemuOpts
On Wed, May 07, 2014 at 05:58:25PM +0800, Chunyan Liu wrote: This patch series is to replace QEMUOptionParameter with QemuOpts, so that only one Qemu Option structure is kept in QEMU code. --- Changes to v26: * Following Eric's comment, backward split 2/33, 3/33. (repurpose qemu_opts_print first, add def_value_str to QemuOptDesc later). * Fix memory free in qemu_opts_append to solve iotest issue. 10/33 * Following Eric's comment, remove the end '.' in error message. And update qemu-iotests .out file. 12/33 * Following Eric's comment, fix memory free in vvfat.c 13/33 * Following Eric's comment, split qcow2 patch into two. 19/33, 20/33: export qemu_opt_find first, add qcow2 driver patch later. * rebase to git master All patches are also available from: https://github.com/chunyanliu/qemu/commits/QemuOpts Please git rebase -x 'make make check make check-block' -i master: qemu-img.c: In function ‘print_block_option_help’: qemu-img.c:289:36: error: ‘create_options’ undeclared (first use in this function) free_option_parameters(create_options); ^
Re: [Qemu-devel] [PATCH resend] block: fix wrong order in live block migration setup
On Wed, Jun 04, 2014 at 11:47:37AM +0800, chai wen wrote: The function init_blk_migration is better to be called before set_dirty_tracking as the reasons below. If we want to track dirty blocks via dirty_maps on a BlockDriverState when doing live block-migration, its correspoding 'BlkMigDevState' should be added to block_mig_state.bmds_list first for subsequent processing. Otherwise set_dirty_tracking will do nothing on an empty list than allocating dirty_bitmaps for them. And bdrv_get_dirty_count will access the bmds-dirty_maps directly, then there would be a segfault triggered. If the set_dirty_tracking fails, qemu_savevm_state_cancel will handle the cleanup of init_blk_migration automatically. Reviewed-by: Fam Zheng f...@redhat.com Signed-off-by: chai wen chaiw.f...@cn.fujitsu.com --- block-migration.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) Thanks, applied to my block tree: https://github.com/stefanha/qemu/commits/block Stefan
Re: [Qemu-devel] [PATCH 5/5] virtio-blk: Drop VirtIOBlockReq.read
On Tue, Jun 03, 2014 at 03:37:29PM +0200, Paolo Bonzini wrote: QEMUIOVector *inhdr;/* iovecs for virtio_blk_inhdr */ This can be unified with the in field; the status is only one byte, so using a full-blown QEMUIOVector is overkill. Stefan, what do you think? I thought about this when initially writing the code, but it seemed like a hack to assume virtio_blk_inhdr will always be 1 byte. virtio-blk is unlikely to change much since the focus is on virtio-scsi rather than piling on more virtio-blk feature. I still prefer we treat it like a struct without making size assumptions, but if the code turns out to be nicer then I don't mind. Stefan
Re: [Qemu-devel] [PATCH v3 0/4] cpus: Add generic NMI support
On 06/04/2014 07:16 PM, Peter Maydell wrote: On 4 June 2014 09:08, Alexey Kardashevskiy a...@ozlabs.ru wrote: This adds an NMI handler per CPUs. x86, s390 and ppc CPUS are supported. The change to existing behaviour is that x86 only delivers NMI to the current monitored CPU now, not to every CPU. So this series means that the nmi command and handler does * NMI on x86 * reset on PPC The vector is called reset but it is an interrupt, and I do not see any way to mask it. * restart on S390 The vector is called restart but it is still an interrupt. That doesn't seem generic at all, and suggests this should not be a common CPU method/callback. Oh. Ok. Suggestions? -- Alexey
Re: [Qemu-devel] [PATCH v2] qemu-img: Document check exit codes
On Mon, Jun 02, 2014 at 10:15:21PM +0200, Max Reitz wrote: The exit code 63 (check not supported by image format) was not even documented in the comment above the check command in the source code; add it, as it does indeed seem useful. Also, document all of check's exit codes in the manpage. Signed-off-by: Max Reitz mre...@redhat.com Reported-by: Markus Armbruster arm...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com --- v2: Fixed spelling mistakes [Eric] --- qemu-img.c| 9 + qemu-img.texi | 23 +++ 2 files changed, 28 insertions(+), 4 deletions(-) Thanks, applied to my block tree: https://github.com/stefanha/qemu/commits/block Stefan
Re: [Qemu-devel] [PATCH v3 0/4] cpus: Add generic NMI support
On 4 June 2014 10:30, Alexey Kardashevskiy a...@ozlabs.ru wrote: On 06/04/2014 07:16 PM, Peter Maydell wrote: On 4 June 2014 09:08, Alexey Kardashevskiy a...@ozlabs.ru wrote: This adds an NMI handler per CPUs. x86, s390 and ppc CPUS are supported. The change to existing behaviour is that x86 only delivers NMI to the current monitored CPU now, not to every CPU. So this series means that the nmi command and handler does * NMI on x86 * reset on PPC The vector is called reset but it is an interrupt, and I do not see any way to mask it. * restart on S390 The vector is called restart but it is still an interrupt. So? ARM has an interrupt called NMI but there's zero reason you'd want to poke it from the monitor, any more than you'd want to try to hand-send any other kind of interrupt. That doesn't seem generic at all, and suggests this should not be a common CPU method/callback. Oh. Ok. Suggestions? I dunno. What are you actually trying to achieve? thanks -- PMM
Re: [Qemu-devel] [PATCH-trivial] arch_init.c: Free 'cache' in cache_fini() to avoid memory leak
* Chen Gang (gang.chen.5...@gmail.com) wrote: Call g_free() after cache_fini() in migration_end(), but do not call g_free() after call cache_fini() in xbzrle_cache_resize() which will cause memory leak. cache_init() and cache_fini() are pair, so need let cache_fini() call g_free(cache) to match cache_init(), then fix current issue too. Signed-off-by: Chen Gang gang.chen.5...@gmail.com Yes, good catch. Reviewed-by: Dr. David Alan Gilbert dgilb...@redhat.com --- arch_init.c | 1 - page_cache.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/arch_init.c b/arch_init.c index 9f1a174..23044c1 100644 --- a/arch_init.c +++ b/arch_init.c @@ -739,7 +739,6 @@ static void migration_end(void) XBZRLE_cache_lock(); if (XBZRLE.cache) { cache_fini(XBZRLE.cache); -g_free(XBZRLE.cache); g_free(XBZRLE.encoded_buf); g_free(XBZRLE.current_buf); XBZRLE.cache = NULL; diff --git a/page_cache.c b/page_cache.c index b033681..89bb1ec 100644 --- a/page_cache.c +++ b/page_cache.c @@ -109,6 +109,7 @@ void cache_fini(PageCache *cache) g_free(cache-page_cache); cache-page_cache = NULL; +g_free(cache); } static size_t cache_get_cache_pos(const PageCache *cache, -- 1.7.11.7 -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK
Re: [Qemu-devel] [PATCH v3 0/4] cpus: Add generic NMI support
On 04.06.14 11:33, Peter Maydell wrote: On 4 June 2014 10:30, Alexey Kardashevskiy a...@ozlabs.ru wrote: On 06/04/2014 07:16 PM, Peter Maydell wrote: On 4 June 2014 09:08, Alexey Kardashevskiy a...@ozlabs.ru wrote: This adds an NMI handler per CPUs. x86, s390 and ppc CPUS are supported. The change to existing behaviour is that x86 only delivers NMI to the current monitored CPU now, not to every CPU. So this series means that the nmi command and handler does * NMI on x86 * reset on PPC The vector is called reset but it is an interrupt, and I do not see any way to mask it. * restart on S390 The vector is called restart but it is still an interrupt. So? ARM has an interrupt called NMI but there's zero reason you'd want to poke it from the monitor, any more than you'd want to try to hand-send any other kind of interrupt. That doesn't seem generic at all, and suggests this should not be a common CPU method/callback. Oh. Ok. Suggestions? I dunno. What are you actually trying to achieve? Linux configures certain interrupts to trigger an emergency situation - usually to get you into a debugger or to start a crash kexec kernel. The command is called nmi because it originally was used on x86 to do this and there the NMI interrupt is the one Linux uses for that purpose. In fact, on x86 bringup systems you often have an NMI button next to the reset and power on buttons. Alex
Re: [Qemu-devel] [PATCH v3 0/4] cpus: Add generic NMI support
On 06/04/2014 07:33 PM, Peter Maydell wrote: On 4 June 2014 10:30, Alexey Kardashevskiy a...@ozlabs.ru wrote: On 06/04/2014 07:16 PM, Peter Maydell wrote: On 4 June 2014 09:08, Alexey Kardashevskiy a...@ozlabs.ru wrote: This adds an NMI handler per CPUs. x86, s390 and ppc CPUS are supported. The change to existing behaviour is that x86 only delivers NMI to the current monitored CPU now, not to every CPU. So this series means that the nmi command and handler does * NMI on x86 * reset on PPC The vector is called reset but it is an interrupt, and I do not see any way to mask it. * restart on S390 The vector is called restart but it is still an interrupt. So? ARM has an interrupt called NMI but there's zero reason you'd want to poke it from the monitor, any more than you'd want to try to hand-send any other kind of interrupt. That doesn't seem generic at all, and suggests this should not be a common CPU method/callback. Oh. Ok. Suggestions? I dunno. What are you actually trying to achieve? I personally want to get XMON (in-kernel debugger) on PPC. -- Alexey
Re: [Qemu-devel] [PATCH v3 0/4] cpus: Add generic NMI support
Il 04/06/2014 11:33, Peter Maydell ha scritto: On 4 June 2014 10:30, Alexey Kardashevskiy a...@ozlabs.ru wrote: On 06/04/2014 07:16 PM, Peter Maydell wrote: On 4 June 2014 09:08, Alexey Kardashevskiy a...@ozlabs.ru wrote: This adds an NMI handler per CPUs. x86, s390 and ppc CPUS are supported. The change to existing behaviour is that x86 only delivers NMI to the current monitored CPU now, not to every CPU. So this series means that the nmi command and handler does * NMI on x86 * reset on PPC The vector is called reset but it is an interrupt, and I do not see any way to mask it. * restart on S390 The vector is called restart but it is still an interrupt. So? ARM has an interrupt called NMI but there's zero reason you'd want to poke it from the monitor, any more than you'd want to try to hand-send any other kind of interrupt. That doesn't seem generic at all, and suggests this should not be a common CPU method/callback. Oh. Ok. Suggestions? I dunno. What are you actually trying to achieve? It's a kind of emergency button on real machines. On PCs it sends an NMI and this results in some kind of crash dump if the OS is configured appropriately. The command may be ill-named for historical reasons, but the effect is not x86-specific. Paolo
Re: [Qemu-devel] [PATCH v3 0/4] cpus: Add generic NMI support
On 4 June 2014 10:39, Paolo Bonzini pbonz...@redhat.com wrote: It's a kind of emergency button on real machines. On PCs it sends an NMI and this results in some kind of crash dump if the OS is configured appropriately. The command may be ill-named for historical reasons, but the effect is not x86-specific. OK, so our callback function name should be sensibly named to match what the effect is supposed to be, and we should have a sensibly named command, and we should make nmi be a historical-legacy-backwards-compatibility command alias (possibly only exposed for x86). thanks -- PMM
Re: [Qemu-devel] [PATCH v3 0/4] cpus: Add generic NMI support
On 04.06.14 11:47, Peter Maydell wrote: On 4 June 2014 10:39, Paolo Bonzini pbonz...@redhat.com wrote: It's a kind of emergency button on real machines. On PCs it sends an NMI and this results in some kind of crash dump if the OS is configured appropriately. The command may be ill-named for historical reasons, but the effect is not x86-specific. OK, so our callback function name should be sensibly named to match what the effect is supposed to be, and we should have a sensibly named command, and we should make nmi be a historical-legacy-backwards-compatibility command alias (possibly only exposed for x86). I honestly don't have a better name :). Alex
Re: [Qemu-devel] [PATCH v2] thread-pool: fix deadlock when callbacks depends on each other
On Mon, Jun 02, 2014 at 09:15:27AM +0200, Marcin Gibuła wrote: When two coroutines submit I/O and first coroutine depends on second to complete (by calling bdrv_drain_all), deadlock may occur. bdrv_drain_all() is a very heavy-weight operation. Coroutines should avoid it if possible. Please post the file/line/function where this call was made, perhaps there is a better way to wait for the other coroutine. This isn't a fix for this bug but it's a cleanup. This is because both requests may have completed before thread pool notifier got called. Then, when notifier gets executed and first coroutine calls aio_pool() to make progress, it will hang forever, as notifier's descriptor has been already marked clear. This patch fixes this, by deferring clearing notifier until no completions are pending. Without this patch, I could reproduce this bug with snapshot-commit with about 1 per 10 tries. With this patch, I couldn't reproduce it any more. Signed-off-by: Marcin Gibula m.gib...@beyond.pl --- This is an interesting bug that definitely needs a test case to prevent regressions in the future. Please take a look at tests/test-thread-pool.c and add a test to it. It can be reproduced deterministically - just call aio_poll() after the dummy worker functions have both completed. Then the next aio_poll() call in the thread pool callback will suffer the problem you described. Stefan
Re: [Qemu-devel] [PATCH-trivial] arch_init.c: Always be sure that 'encoded_buf' and 'current_buf' are lock protected
* Chen Gang (gang.chen.5...@gmail.com) wrote: Firstly, thank you very much for reviewing the related 2 patches. On 06/03/2014 03:31 PM, ChenLiang wrote: On 2014/6/2 20:35, Chen Gang wrote: 'encoded_buf' and 'current_buf' are lock protected during using in save_xbzrle_page() in ram_save_page(), and during freeing in migration_end(). So recommend to let them lock protected during starting, just like we have done to 'cache'. This isn't one for Trivial - it needs some thought. Locks always need thought. Signed-off-by: Chen Gang gang.chen.5...@gmail.com --- arch_init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch_init.c b/arch_init.c index 23044c1..784922c 100644 --- a/arch_init.c +++ b/arch_init.c @@ -783,12 +783,12 @@ static int ram_save_setup(QEMUFile *f, void *opaque) error_report(Error creating cache); return -1; } -XBZRLE_cache_unlock(); /* We prefer not to abort if there is no memory */ XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE); if (!XBZRLE.encoded_buf) { error_report(Error allocating encoded_buf); +XBZRLE_cache_unlock(); return -1; } @@ -797,8 +797,10 @@ static int ram_save_setup(QEMUFile *f, void *opaque) error_report(Error allocating current_buf); g_free(XBZRLE.encoded_buf); XBZRLE.encoded_buf = NULL; +XBZRLE_cache_unlock(); return -1; } +XBZRLE_cache_unlock(); acct_clear(); } It isn't necessary. For me, it is still necessary to be improved. - If this code is not performance sensitive: always lock protected will let source code easy understanding for readers, and easy sustainable for maintainers. - Else (performance sensitive): Need give related comments to it (e.g. for performance reason, let it out of lock protected). So readers easily understand, and the related maintainers may notice about it at any time. It is not good to give comments in a function, except the code is not used in normal way. I think the locks for the cache were originally there to handle the race between a resize (on the main thread) against the use (in the migration thread). That doesn't happen for the encoded_buf so I don't think we have that problem. Is there any other case that it could race? I can't see one - I think all of the other start/end is done within the migration thread. Dave Thanks. -- Chen Gang Open, share, and attitude like air, water, and life which God blessed -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK
Re: [Qemu-devel] [PATCH v2 1/8] enable sharing of the function between migration and bitmap dump
Sanidhya Kashyap sanidhya.ii...@gmail.com wrote: As advised by Eric, I have enabled sharing of the function between of the function that syncs the dirty bitmap obtained via kvm ioctl. I have tried to make the least changes to the functions by concentrating only on the function definitions. Signed-off-by: Sanidhya Kashyap sanidhya.ii...@gmail.com --- arch_init.c | 19 +++ include/exec/ram_addr.h | 4 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/arch_init.c b/arch_init.c index 685ba0e..48eb90a 100644 --- a/arch_init.c +++ b/arch_init.c @@ -434,20 +434,22 @@ ram_addr_t migration_bitmap_find_and_reset_dirty(MemoryRegion *mr, return (next - base) TARGET_PAGE_BITS; } -static inline bool migration_bitmap_set_dirty(ram_addr_t addr) +static inline bool bitmap_set_dirty(ram_addr_t addr, unsigned long *bitmap, + bool migration_flag) Exporting a function without a prefix could be dangerous. Later, Juan.
Re: [Qemu-devel] [PATCH v2 3/8] RunState: added two new flags for bitmap dump and migration process
* Sanidhya Kashyap (sanidhya.ii...@gmail.com) wrote: I have added two new flags - RUN_STATE_MIGRATE and RUN_STATE_DUMP_BITMAP. These both flags behave same as RUN_STATE_RUNNING flag. The purpose of introducing these flags is to avoid running both migration and dump bitmap process simultaneously. I haven't added many transitions to the RUN_STATE_DUMP_BITMAP. I will try to include the transitions on the basis of discussions. On the other hand, I have tried to add the transitions that might occur during the migration process. There is a possibility that some transitions can be redundant (as pointed by Chen, this is not my patch problem, but I have tried to cover what I thought is necessary). I find runstate to be very subtle; there are probably other things that would need changing; e.g. I see the USB code has: if (state == RUN_STATE_RUNNING) { and if (!runstate_check(RUN_STATE_RUNNING)) { (it should probably be using runstate_is_running() ) Also virt-test tends to see the state (I don't know if libvirt etc do?) so they may get confused. Dave Signed-off-by: Sanidhya Kashyap sanidhya.ii...@gmail.com --- qapi-schema.json | 7 ++- vl.c | 29 - 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 17e5147..2918fc4 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -234,12 +234,17 @@ # @watchdog: the watchdog action is configured to pause and has been triggered # # @guest-panicked: guest has been panicked as a result of guest OS panic +# +# @migrate: migration process is being executed +# +# @dump-bitmap: dump the writable working set of the guest +# ## { 'enum': 'RunState', 'data': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paused', 'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm', 'running', 'save-vm', 'shutdown', 'suspended', 'watchdog', -'guest-panicked' ] } +'guest-panicked', 'migrate', 'dump-bitmap' ] } ## # @SnapshotInfo diff --git a/vl.c b/vl.c index 709d8cd..a2ffd66 100644 --- a/vl.c +++ b/vl.c @@ -576,31 +576,39 @@ static const RunStateTransition runstate_transitions_def[] = { /* from - to */ { RUN_STATE_DEBUG, RUN_STATE_RUNNING }, { RUN_STATE_DEBUG, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_DEBUG, RUN_STATE_MIGRATE }, { RUN_STATE_INMIGRATE, RUN_STATE_RUNNING }, { RUN_STATE_INMIGRATE, RUN_STATE_PAUSED }, { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED }, { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_INTERNAL_ERROR, RUN_STATE_MIGRATE }, { RUN_STATE_IO_ERROR, RUN_STATE_RUNNING }, { RUN_STATE_IO_ERROR, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_IO_ERROR, RUN_STATE_MIGRATE }, { RUN_STATE_PAUSED, RUN_STATE_RUNNING }, { RUN_STATE_PAUSED, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_PAUSED, RUN_STATE_MIGRATE }, { RUN_STATE_POSTMIGRATE, RUN_STATE_RUNNING }, { RUN_STATE_POSTMIGRATE, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_POSTMIGRATE, RUN_STATE_MIGRATE }, { RUN_STATE_PRELAUNCH, RUN_STATE_RUNNING }, { RUN_STATE_PRELAUNCH, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, +{ RUN_STATE_PRELAUNCH, RUN_STATE_MIGRATE }, { RUN_STATE_FINISH_MIGRATE, RUN_STATE_RUNNING }, { RUN_STATE_FINISH_MIGRATE, RUN_STATE_POSTMIGRATE }, { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING }, +{ RUN_STATE_DUMP_BITMAP, RUN_STATE_RUNNING}, + { RUN_STATE_RUNNING, RUN_STATE_DEBUG }, { RUN_STATE_RUNNING, RUN_STATE_INTERNAL_ERROR }, { RUN_STATE_RUNNING, RUN_STATE_IO_ERROR }, @@ -611,6 +619,8 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_RUNNING, RUN_STATE_SHUTDOWN }, { RUN_STATE_RUNNING, RUN_STATE_WATCHDOG }, { RUN_STATE_RUNNING, RUN_STATE_GUEST_PANICKED }, +{ RUN_STATE_RUNNING, RUN_STATE_DUMP_BITMAP }, +{ RUN_STATE_RUNNING, RUN_STATE_MIGRATE }, { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING }, @@ -621,12 +631,27 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_RUNNING, RUN_STATE_SUSPENDED }, { RUN_STATE_SUSPENDED, RUN_STATE_RUNNING }, { RUN_STATE_SUSPENDED, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_SUSPENDED, RUN_STATE_MIGRATE }, { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING }, { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_WATCHDOG, RUN_STATE_MIGRATE }, { RUN_STATE_GUEST_PANICKED, RUN_STATE_RUNNING }, { RUN_STATE_GUEST_PANICKED, RUN_STATE_FINISH_MIGRATE }, +{ RUN_STATE_GUEST_PANICKED, RUN_STATE_MIGRATE }, + +{ RUN_STATE_DUMP_BITMAP, RUN_STATE_RUNNING }, + +{ RUN_STATE_MIGRATE, RUN_STATE_POSTMIGRATE }, +{ RUN_STATE_MIGRATE, RUN_STATE_PAUSED }, +{ RUN_STATE_MIGRATE,
Re: [Qemu-devel] [PATCH v2 4/6] target-arm: add emulation of PSCI calls for system emulation
On Tue, Jun 3, 2014 at 6:14 AM, Peter Maydell peter.mayd...@linaro.org wrote: On 23 May 2014 03:30, Rob Herring robherri...@gmail.com wrote: From: Rob Herring rob.herr...@linaro.org Add support for handling PSCI calls in system emulation. Both version 0.1 and 0.2 of the PSCI spec are supported. Platforms can enable support by setting psci-method QOM property on the cpus to SMC or HVC emulation and having PSCI binding in their dtb. diff --git a/target-arm/psci.c b/target-arm/psci.c new file mode 100644 index 000..88af3f9 --- /dev/null +++ b/target-arm/psci.c @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2014 - Linaro + * Author: Rob Herring rob.herr...@linaro.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + */ +#include cpu.h +#include cpu-qom.h +#include kvm-consts.h +#include sysemu/sysemu.h +#include linux/psci.h This won't build on non-Linux hosts: you can't assume the linux-headers/ includes are available except within code guarded by CONFIG_KVM. What do you suggest doing here then. Really, psci.h is OS independent. Can we copy it to somewhere else in the qemu tree? Rob
Re: [Qemu-devel] [Bug 1324112] [NEW] qemu parallel building error on libcacard.la
Version 2.0.0 Isn’t the libcacard Makefile run as a recursive make? how do you keep the dependencies between two different makes(libcacard and trace)? -Original Message- From: boun...@canonical.com [mailto:boun...@canonical.com] On Behalf Of Stefan Hajnoczi Sent: Wednesday, June 04, 2014 11:19 AM To: Tal Zilcer Subject: Re: [Qemu-devel] [Bug 1324112] [NEW] qemu parallel building error on libcacard.la On Wed, May 28, 2014 at 12:52:10PM -, tal zilcer wrote: im building qemu with a large make -j value(9). sometimes the build fails because of an error: libtool: link: ar cru .libs/libcacard.a stubs/arch-query-cpu-def.o stubs/clock-warp.o stubs/cpu-get-clock.o stubs/cpu-get-icount.o stubs/dump.o stubs/fdset-add-fd.o stubs/fdset-find-fd.o stubs/fdset-get-fd.o stubs/fdset-remove-fd.o stubs/gdbstub.o stubs/get-fd.o stubs/get-vm-name.o stubs/iothread-lock.o stubs/migr-blocker.o stubs/mon-is-qmp.o stubs/mon-printf.o stubs/mon-print-filename.o stubs/mon-protocol-event.o stubs/mon-set-error.o stubs/pci-drive-hot-add.o stubs/qtest.o stubs/reset.o stubs/runstate-check.o stubs/set-fd-handler.o stubs/slirp.o stubs/sysbus.o stubs/uuid.o stubs/vm-stop.o stubs/vmstate.o stubs/cpus.o stubs/kvm.o libcacard/cac.o libcacard/event.o libcacard/vcard.o libcacard/vreader.o libcacard/vcard_emul_nss.o libcacard/vcard_emul_type.o libcacard/card_7816.o libcacard/vcardt.o util/osdep.o util/cutils.o util/qemu-timer-common.o util/error.o util/qemu-error.o util/oslib-posix.o util/qemu-thread-posix.o trace/generated-events.o trace/default.o trace/control.o trace/generated-tracers.o ar: trace/generated-events.o: No such file or directory make[2]: *** [libcacard.la] Error 1 i see the build of generated-events.o in the log before the ar command. because of the -j it was probably not completed yet. the generated-events.o build command: /usr/bin/gcc -I/home/npsdb/qemu/qemu/tcg -I/home/npsdb/qemu/qemu/tcg/i386 -I/home/npsdb/qemu/qemu/linux-headers -I/home/npsdb/qemu/build/linux_x86_64/linux-headers -I. -I/home/npsdb/qemu/qemu -I/home/npsdb/jenkins/qemu/qemu/include -I/home/npsdb/qemu/qemu/libcacard -Itrace -Itrace -fPIE -DPIE -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-all -I/usr/include/libpng12 -I/usr/include/nss3 -I/usr/include/nspr4 -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/home/npsdb/qemu/qemu/tests -I qga/qapi-generated -MMD -MP -MT trace/generated-events.o -MF trace/generated-events.d -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -g -c -o trace/generated-events.o trace/generated-events.c must be a race condition in the makefile because of a missing dependency. i tried to find it but it was a little bit complicated to me. Which QEMU version are you building? In qemu.git/master I can see the dependency on trace/* in libcacard/Makefile. Stefan -- You received this bug notification because you are subscribed to the bug report. https://bugs.launchpad.net/bugs/1324112 Title: qemu parallel building error on libcacard.la Status in QEMU: New Bug description: hi, im building qemu with a large make -j value(9). sometimes the build fails because of an error: libtool: link: ar cru .libs/libcacard.a stubs/arch-query-cpu-def.o stubs/clock-warp.o stubs/cpu-get-clock.o stubs/cpu-get-icount.o stubs/dump.o stubs/fdset-add-fd.o stubs/fdset-find-fd.o stubs/fdset-get-fd.o stubs/fdset-remove-fd.o stubs/gdbstub.o stubs/get-fd.o stubs/get-vm-name.o stubs/iothread-lock.o stubs/migr-blocker.o stubs/mon-is-qmp.o stubs/mon-printf.o stubs/mon-print-filename.o stubs/mon-protocol-event.o stubs/mon-set-error.o stubs/pci-drive-hot-add.o stubs/qtest.o stubs/reset.o stubs/runstate-check.o stubs/set-fd-handler.o stubs/slirp.o stubs/sysbus.o stubs/uuid.o stubs/vm-stop.o stubs/vmstate.o stubs/cpus.o stubs/kvm.o libcacard/cac.o libcacard/event.o libcacard/vcard.o libcacard/vreader.o libcacard/vcard_emul_nss.o libcacard/vcard_emul_type.o libcacard/card_7816.o libcacard/vcardt.o util/osdep.o util/cutils.o util/qemu-timer-common.o util/error.o util/qemu-error.o util/oslib-posix.o util/qemu-thread-posix.o trace/generated-events.o trace/default.o trace/control.o trace/generated-tracers.o ar: trace/generated-events.o: No such file or directory make[2]: *** [libcacard.la] Error 1 i see the build of generated-events.o in the log before the ar command. because of the -j it was probably not completed yet. the generated-events.o build command: /usr/bin/gcc
Re: [Qemu-devel] [PATCH v2 2/8] bitmap dump code via QAPI framework
* Sanidhya Kashyap (sanidhya.ii...@gmail.com) wrote: Following are the changes made with respect to the previous version: Chen's advice +if (qemu_write_full(fd, ram_bitmap_pages, sizeof(int64_t)) 0) { +b-state = LOG_BITMAP_STATE_ERROR; +goto log_thread_end; +} + +/* + * sync the dirty bitmap along with saving it + * using the FILE pointer f. + */ +while (epoch_count total_epochs) { +if (!runstate_is_running() || b-state != LOG_BITMAP_STATE_ACTIVE) { +goto log_thread_end; +} +bitmap_zero(logging_bitmap, ram_bitmap_pages); +logging_lock(); +dirty_bitmap_sync(); +logging_unlock(); +if (qemu_write_full(fd, logging_bitmap, bitmap_size) 0) { +b-state = LOG_BITMAP_STATE_ERROR; +goto log_thread_end; +} +g_usleep(b-current_frequency * 1000); +epoch_count++; +} I wonder about adding two extra things to the file format: 1) The block names/length/offset information - so that you can tell that bitmap entry 'n' is from main ram or from video ram. 2) A marker word between/after each bitmap with a known value - it would help spot any error where the wrong length is being read in the scripts; otherwise it would be easy to get misaligned bitmaps without really noticing. Dave + +/* + * stop the logging period. + */ + log_thread_end: +logging_bitmap_close(b); +if (b-state == LOG_BITMAP_STATE_ACTIVE) { +logging_state_set_status(b, LOG_BITMAP_STATE_ACTIVE, +LOG_BITMAP_STATE_COMPLETED); +} else if (b-state == LOG_BITMAP_STATE_CANCELING) { +logging_state_set_status(b, LOG_BITMAP_STATE_CANCELING, +LOG_BITMAP_STATE_COMPLETED); +} else if (b-state == LOG_BITMAP_STATE_ERROR) { +logging_state_set_status(b, LOG_BITMAP_STATE_ERROR, +LOG_BITMAP_STATE_COMPLETED); +} +return NULL; +} + +void qmp_log_dirty_bitmap(const char *filename, bool has_epochs, + int64_t epochs, bool has_frequency, + int64_t frequency, Error **errp) +{ +int fd = -1; +BitmapLogState *b = logging_current_state(); +Error *local_err = NULL; +if (b-state == LOG_BITMAP_STATE_ACTIVE || +b-state == LOG_BITMAP_STATE_SETUP || +b-state == LOG_BITMAP_STATE_CANCELING) { +b = NULL; +error_setg(errp, dirty bitmap dump in progress); +return; +} + +if (b-state == LOG_BITMAP_STATE_COMPLETED) { +b-state = LOG_BITMAP_STATE_NONE; +} + +if (!has_epochs) { +epochs = MIN_EPOCH_VALUE; +} +if (!has_frequency) { +frequency = MIN_FREQUENCY_VALUE; +} + +if (!check_value(epochs, MIN_EPOCH_VALUE, epoch, local_err) || +!check_value(frequency, MIN_FREQUENCY_VALUE, frequency, local_err)) { +if (local_err) { +b = NULL; +error_propagate(errp, local_err); +return; +} +} + +fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR); +if (fd 0) { +error_setg_file_open(errp, errno, filename); +b = NULL; +return; +} + +b-total_epochs = epochs; +b-current_frequency = frequency; +b-fd = fd; +qemu_thread_create(b-thread, dirty-bitmap-dump, + bitmap_logging_thread, b, + QEMU_THREAD_JOINABLE); + +return; +} + void qmp_xen_save_devices_state(const char *filename, Error **errp) { QEMUFile *f; -- 1.8.3.1 -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK
Re: [Qemu-devel] [PATCH v2 1/8] enable sharing of the function between migration and bitmap dump
Exporting a function without a prefix could be dangerous. Later, Juan. Any particular solution, as the function is being used at two places. -- Sanidhya Kashyap
Re: [Qemu-devel] [PATCH v2 4/6] target-arm: add emulation of PSCI calls for system emulation
On 4 June 2014 11:09, Rob Herring robherri...@gmail.com wrote: On Tue, Jun 3, 2014 at 6:14 AM, Peter Maydell peter.mayd...@linaro.org wrote: This won't build on non-Linux hosts: you can't assume the linux-headers/ includes are available except within code guarded by CONFIG_KVM. What do you suggest doing here then. Really, psci.h is OS independent. Can we copy it to somewhere else in the qemu tree? Only if you can guarantee that it won't clash with the one that is in the linux-headers/ tree, or the one in /usr/include, ie that it doesn't matter which of those three we pick up. That pretty much means kernel KVM headers can't ever rely on new PSCI constants being added to psci.h so that doesn't seem like it's going to work. Otherwise it would need to be copy-and-rename-symbols, same as we do for anything else where we need them outside the KVM code. I agree that's pretty ugly. thanks -- PMM
Re: [Qemu-devel] [PATCH v2] thread-pool: fix deadlock when callbacks depends on each other
Il 04/06/2014 12:01, Stefan Hajnoczi ha scritto: Without this patch, I could reproduce this bug with snapshot-commit with about 1 per 10 tries. With this patch, I couldn't reproduce it any more. Signed-off-by: Marcin Gibula m.gib...@beyond.pl --- This is an interesting bug that definitely needs a test case to prevent regressions in the future. Please take a look at tests/test-thread-pool.c and add a test to it. It can be reproduced deterministically - just call aio_poll() after the dummy worker functions have both completed. Then the next aio_poll() call in the thread pool callback will suffer the problem you described. The question if we want to consider this thread-pool.c behavior a real bug or just a misfeature (the real bug being elsewhere). Even though this patch avoids the performance problems of v1, we would have to fix at least two other cases and it's not obvious (a) that those two are the only ones (b) tgat those two can be fixed without affecting performance. If the bottom half code is immune from this event notifier problem, bdrv_drain/bdrv_drain_all calls in coroutine context can defer the actual draining to a bottom half and reenter the coroutine afterwards; we can then audit that all other calls should come from the main loop rather than aio_poll. Paolo