Re: [Qemu-devel] [PATCH V3 2/7] qemu-nbd: support internal snapshot export
于 2013/10/2 0:08, Paolo Bonzini 写道: Il 26/09/2013 02:16, Wenchao Xia ha scritto: Now it is possible to directly export an internal snapshot, which can be used to probe the snapshot's contents without qemu-img convert. Signed-off-by: Wenchao Xiaxiaw...@linux.vnet.ibm.com --- block/snapshot.c | 18 ++ include/block/snapshot.h |6 ++ qemu-nbd.c | 35 ++- 3 files changed, 58 insertions(+), 1 deletions(-) diff --git a/block/snapshot.c b/block/snapshot.c index 2ae3099..b371c27 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -25,6 +25,24 @@ #include block/snapshot.h #include block/block_int.h +QemuOptsList internal_snapshot_opts = { +.name = snapshot, +.head = QTAILQ_HEAD_INITIALIZER(internal_snapshot_opts.head), +.desc = { +{ +.name = SNAPSHOT_OPT_ID, Why not just use id and name? Later it is used by code: qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID), The macro is used to avoid type it twice in the codes, shouldn't it be used? Another reason not using id is because string id is treated as special case in opts_parse() so I choosed string snapshot.id. +.type = QEMU_OPT_STRING, +.help = snapshot id +},{ +.name = SNAPSHOT_OPT_NAME, +.type = QEMU_OPT_STRING, +.help = snapshot name +},{ +/* end of list */ +} +}, +}; + int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info, const char *name) { diff --git a/include/block/snapshot.h b/include/block/snapshot.h index d05bea7..c524a49 100644 --- a/include/block/snapshot.h +++ b/include/block/snapshot.h @@ -27,6 +27,12 @@ #include qemu-common.h #include qapi/error.h +#include qemu/option.h + +#define SNAPSHOT_OPT_ID snapshot.id +#define SNAPSHOT_OPT_NAME snapshot.name + +extern QemuOptsList internal_snapshot_opts; typedef struct QEMUSnapshotInfo { char id_str[128]; /* unique snapshot id */ diff --git a/qemu-nbd.c b/qemu-nbd.c index c26c98e..6588a1f 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -20,6 +20,7 @@ #include block/block.h #include block/nbd.h #include qemu/main-loop.h +#include block/snapshot.h #includestdarg.h #includestdio.h @@ -315,7 +316,9 @@ int main(int argc, char **argv) char *device = NULL; int port = NBD_DEFAULT_PORT; off_t fd_size; -const char *sopt = hVb:o:p:rsnP:c:dvk:e:f:t; +QemuOpts *sn_opts = NULL; +const char *sn_id_or_name = NULL; +const char *sopt = hVb:o:p:rsnP:c:dvk:e:f:tl:L:; struct option lopt[] = { { help, 0, NULL, 'h' }, { version, 0, NULL, 'V' }, @@ -328,6 +331,8 @@ int main(int argc, char **argv) { connect, 1, NULL, 'c' }, { disconnect, 0, NULL, 'd' }, { snapshot, 0, NULL, 's' }, +{ load-snapshot, 1, NULL, 'l' }, Just omit the long option here... +{ load-snapshot1, 1, NULL, 'L' }, ... and call this load-snapshot. Paolo OK, I will change as: { NULL, 1, NULL, 'l' }, { load-snapshot, 1, NULL, 'L' }, { nocache, 0, NULL, 'n' }, { cache, 1, NULL, QEMU_NBD_OPT_CACHE }, #ifdef CONFIG_LINUX_AIO @@ -428,6 +433,14 @@ int main(int argc, char **argv) errx(EXIT_FAILURE, Offset must be positive `%s', optarg); } break; +case 'l': +sn_id_or_name = optarg; +nbdflags |= NBD_FLAG_READ_ONLY; +flags= ~BDRV_O_RDWR; +break; +case 'L': +sn_opts = qemu_opts_parse(internal_snapshot_opts, optarg, 0); +/* fall through */ case 'r': nbdflags |= NBD_FLAG_READ_ONLY; flags= ~BDRV_O_RDWR; @@ -581,6 +594,22 @@ int main(int argc, char **argv) error_get_pretty(local_err)); } +if (sn_opts) { +ret = bdrv_snapshot_load_tmp(bs, + qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID), + qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME), +local_err); +} else if (sn_id_or_name) { +ret = bdrv_snapshot_load_tmp_by_id_or_name(bs, sn_id_or_name, +local_err); +} +if (ret 0) { +errno = -ret; +err(EXIT_FAILURE, +Failed to load snapshot: %s, +error_get_pretty(local_err)); +} + fd_size = bdrv_getlength(bs); if (partition != -1) { @@ -641,6 +670,10 @@ int main(int argc, char **argv) unlink(sockpath); } +if (sn_opts) { +qemu_opts_del(sn_opts); +} + if (device) { void *ret; pthread_join(client_thread,ret);
Re: [Qemu-devel] [PATCH V3 3/7] qemu-nbd: add doc for internal snapshot export
于 2013/10/1 22:49, Eric Blake 写道: On 09/25/2013 06:16 PM, Wenchao Xia wrote: Signed-off-by: Wenchao Xiaxiaw...@linux.vnet.ibm.com --- qemu-nbd.c| 11 ++- qemu-nbd.texi | 11 ++- 2 files changed, 20 insertions(+), 2 deletions(-) This should be squashed into 2/7. When adding new options, the documentation should be added at the same time. OK. + the temporary one\n + -l, --load-snapshot=SNAPSHOT_ID_OR_NAME\n + load an internal snapshot inside FILE and export it\n + as an read-only device\n + -L, --load-snapshot1=SNAPSHOT_PARAM\n + load an internal snapshot inside FILE and export it\n + as an read-only device, SNAPSHOT_PARAM format is\n + 'snapshot.id=[ID],snapshot.name=[NAME]'\n Why can't ONE option be good enough? In other words, make the command line parser smart enough so that: --load-snapshot=name tries SNAPSHOT_ID_OR_NAME, while --load-snapshot=snapshot.id=xyz,snapshot.name=name tries the SNAPSHOT_PARAM form. In other words, if the optarg begins with 'snapshot.', assume the SNAPSHOT_PARAM form, otherwise use the SNAPSHOT_ID_OR_NAME form. Then you only burn one short option letter, and avoid the problem with ambiguous abbreviation that I complained about in 2/7. I split the option as two item since want to keep capatiability for -s snapshot.id=xyz in qemu-img convert, it is possible some one already named a snapshot as snapshot.id=xyz. But from the comments of Paolo, I think add a new option in qemu-img convert and deprecate -s, can solve the problem, so I will use your format in next version, thanks for tipping that.
Re: [Qemu-devel] [PATCH V3 5/7] qemu-img: add -L for snapshot in convert
于 2013/10/2 0:07, Paolo Bonzini 写道: Il 26/09/2013 02:16, Wenchao Xia ha scritto: +c = getopt(argc, argv, f:O:B:s:hce6o:pS:t:qnL:); if (c == -1) { break; } @@ -1183,6 +1184,9 @@ static int img_convert(int argc, char **argv) case 's': snapshot_name = optarg; break; +case 'L': +sn_opts = qemu_opts_parse(internal_snapshot_opts, optarg, 0); +break; case 'S': Should qemu-img introduce -l too, and deprecate -s (continue to accept it silently, but not document it)? Paolo OK, will document both but mark it deprecated.
Re: [Qemu-devel] [PATCH V3 4/7] qemu-iotests: add 058 internal snapshot export with qemu-nbd case
于 2013/10/1 22:53, Eric Blake 写道: On 09/25/2013 06:16 PM, Wenchao Xia wrote: Signed-off-by: Wenchao Xiaxiaw...@linux.vnet.ibm.com --- +_export_nbd_snapshot() +{ +eval $QEMU_NBD -v -t -b 127.0.0.1 -p $nbd_snapshot_port $TEST_IMG -l $1 Uggh. Why do you need an eval here? Especially given that there was recently a patch to properly quote $TEST_IMG in case the tests are run inside a directory whose absolute name included a space. What's wrong with just directly: $QEMU_NBD -v -t -b 127.0.0.1 -p $nbd_snapshot_port $TEST_IMG -l $1 $ Just a copy and paste for eval, will remove it. +NBD_SNAPSHOT_PID=$! +sleep 1 +} + +_export_nbd_snapshot1() +{ +eval $QEMU_NBD -v -t -b 127.0.0.1 -p $nbd_snapshot_port $TEST_IMG -L snapshot.name=$1 Likewise; and given my complaint on 2-3/7, it would be nicer to support this with only one option name spelling. +_cleanup() +{ +if [ -n $NBD_SNAPSHOT_PID ]; then +kill $NBD_SNAPSHOT_PID +fi + _cleanup_test_img Kill the TAB, fix the indentation. Will fix. +} +trap _cleanup; exit \$status 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.pattern + +# Any format supporting intenal snapshots s/intenal/internal/ will fix. +_supported_fmt qcow2 +_supported_proto generic +_supported_os Linux Is this test truly Linux-only? I think it is generic, will remove it.
Re: [Qemu-devel] [PATCH V3 6/7] qemu-img: add doc for param -L in convert
于 2013/10/1 22:56, Eric Blake 写道: On 09/25/2013 06:16 PM, Wenchao Xia wrote: Also renamed snapshot_name to snapshot_id_or_name to tip better. s/to tip better/as a better hint of what it does/ Signed-off-by: Wenchao Xiaxiaw...@linux.vnet.ibm.com --- qemu-img-cmds.hx |2 +- qemu-img.c |2 ++ qemu-img.texi|7 +-- 3 files changed, 8 insertions(+), 3 deletions(-) Squash this into 5/7. OK. + 'snapshot_param' is param used for internal snapshot, format is\n + 'snapshot.id=[ID],snapshot.name=[NAME]'\n Again, can you reuse the existing -s, instead of having to add -L, by There may be compatiability issue for existing user, I think add -l and deprecate old -s, would be better. making the command line parser smarter about whether it is seeing a single name vs. a string starting with 'snapshot.'?
Re: [Qemu-devel] [PATCH V3 7/7] qemu-iotests: add test for snapshot in qemu-img convert
于 2013/10/1 22:57, Eric Blake 写道: On 09/25/2013 06:16 PM, Wenchao Xia wrote: Signed-off-by: Wenchao Xiaxiaw...@linux.vnet.ibm.com --- @@ -53,6 +55,7 @@ _cleanup() kill $NBD_SNAPSHOT_PID fi _cleanup_test_img +rm -f $converted_image Indentation is off. will fix.
Re: [Qemu-devel] [PATCH V3 2/7] qemu-nbd: support internal snapshot export
于 2013/10/10 14:00, Wenchao Xia 写道: 于 2013/10/2 0:08, Paolo Bonzini 写道: Il 26/09/2013 02:16, Wenchao Xia ha scritto: Now it is possible to directly export an internal snapshot, which can be used to probe the snapshot's contents without qemu-img convert. Signed-off-by: Wenchao Xiaxiaw...@linux.vnet.ibm.com --- block/snapshot.c | 18 ++ include/block/snapshot.h |6 ++ qemu-nbd.c | 35 ++- 3 files changed, 58 insertions(+), 1 deletions(-) diff --git a/block/snapshot.c b/block/snapshot.c index 2ae3099..b371c27 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -25,6 +25,24 @@ #include block/snapshot.h #include block/block_int.h +QemuOptsList internal_snapshot_opts = { +.name = snapshot, +.head = QTAILQ_HEAD_INITIALIZER(internal_snapshot_opts.head), +.desc = { +{ +.name = SNAPSHOT_OPT_ID, Why not just use id and name? Later it is used by code: qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID), The macro is used to avoid type it twice in the codes, shouldn't it be used? Another reason not using id is because string id is treated as special case in opts_parse() so I choosed string snapshot.id. +.type = QEMU_OPT_STRING, +.help = snapshot id +},{ +.name = SNAPSHOT_OPT_NAME, +.type = QEMU_OPT_STRING, +.help = snapshot name +},{ +/* end of list */ +} +}, +}; + int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info, const char *name) { diff --git a/include/block/snapshot.h b/include/block/snapshot.h index d05bea7..c524a49 100644 --- a/include/block/snapshot.h +++ b/include/block/snapshot.h @@ -27,6 +27,12 @@ #include qemu-common.h #include qapi/error.h +#include qemu/option.h + +#define SNAPSHOT_OPT_ID snapshot.id +#define SNAPSHOT_OPT_NAME snapshot.name + +extern QemuOptsList internal_snapshot_opts; typedef struct QEMUSnapshotInfo { char id_str[128]; /* unique snapshot id */ diff --git a/qemu-nbd.c b/qemu-nbd.c index c26c98e..6588a1f 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -20,6 +20,7 @@ #include block/block.h #include block/nbd.h #include qemu/main-loop.h +#include block/snapshot.h #includestdarg.h #includestdio.h @@ -315,7 +316,9 @@ int main(int argc, char **argv) char *device = NULL; int port = NBD_DEFAULT_PORT; off_t fd_size; -const char *sopt = hVb:o:p:rsnP:c:dvk:e:f:t; +QemuOpts *sn_opts = NULL; +const char *sn_id_or_name = NULL; +const char *sopt = hVb:o:p:rsnP:c:dvk:e:f:tl:L:; struct option lopt[] = { { help, 0, NULL, 'h' }, { version, 0, NULL, 'V' }, @@ -328,6 +331,8 @@ int main(int argc, char **argv) { connect, 1, NULL, 'c' }, { disconnect, 0, NULL, 'd' }, { snapshot, 0, NULL, 's' }, +{ load-snapshot, 1, NULL, 'l' }, Just omit the long option here... +{ load-snapshot1, 1, NULL, 'L' }, ... and call this load-snapshot. Paolo OK, I will change as: { NULL, 1, NULL, 'l' }, { load-snapshot, 1, NULL, 'L' }, From Eric's suggestion, I think simply one item: { load-snapshot, 1, NULL, 'l' } would be engough to handle both cases. { nocache, 0, NULL, 'n' }, { cache, 1, NULL, QEMU_NBD_OPT_CACHE }, #ifdef CONFIG_LINUX_AIO @@ -428,6 +433,14 @@ int main(int argc, char **argv) errx(EXIT_FAILURE, Offset must be positive `%s', optarg); } break; +case 'l': +sn_id_or_name = optarg; +nbdflags |= NBD_FLAG_READ_ONLY; +flags= ~BDRV_O_RDWR; +break; +case 'L': +sn_opts = qemu_opts_parse(internal_snapshot_opts, optarg, 0); +/* fall through */ case 'r': nbdflags |= NBD_FLAG_READ_ONLY; flags= ~BDRV_O_RDWR; @@ -581,6 +594,22 @@ int main(int argc, char **argv) error_get_pretty(local_err)); } +if (sn_opts) { +ret = bdrv_snapshot_load_tmp(bs, + qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID), + qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME), +local_err); +} else if (sn_id_or_name) { +ret = bdrv_snapshot_load_tmp_by_id_or_name(bs, sn_id_or_name, +local_err); +} +if (ret 0) { +errno = -ret; +err(EXIT_FAILURE, +Failed to load snapshot: %s, +error_get_pretty(local_err)); +} + fd_size = bdrv_getlength(bs); if (partition != -1) { @@ -641,6 +670,10 @@ int main(int argc, char **argv) unlink(sockpath); } +if (sn_opts) { +qemu_opts_del(sn_opts); +} + if (device) { void *ret; pthread_join(client_thread,ret);
Re: [Qemu-devel] [patch 1/2] qemu: mempath: prefault pages manually
Il 09/10/2013 23:26, Paolo Bonzini ha scritto: Il 09/10/2013 21:41, Marcelo Tosatti ha scritto: How was that tested? For BUS_MCEERR_AO it can work, but BUS_MCEERR_AR calls force_sig_info which does this: ignored = action-sa.sa_handler == SIG_IGN; blocked = sigismember(t-blocked, sig); if (blocked || ignored) { action-sa.sa_handler = SIG_DFL; if (blocked) { sigdelset(t-blocked, sig); recalc_sigpending_and_wake(t); } if (action-sa.sa_handler == SIG_DFL) t-signal-flags = ~SIGNAL_UNKILLABLE; and kills the process (because that's the default action of SIG_DFL). For vcpu context its not blocked? It causes KVM to exit back to userspace, but as soon as KVM exits it should be blocked. ... but it's been queued and this bypasses the checks in force_sig_info. So in guest mode it is accepted, in QEMU mode it causes a SIGBUS. Paolo
Re: [Qemu-devel] [PATCH 1/2] audio: honor QEMU_AUDIO_TIMER_PERIOD instead of waking up every *nano* second
On 9 Oct 2013, at 20:42, Hans de Goede wrote: Now that we no longer have MIN_REARM_TIMER_NS a bug in the audio subsys has clearly shown it self by trying to make a timer fire every nano second. Note we have a similar problem in 1.6, 1.5 and older but there MIN_REARM_TIMER_NS limits the wakeups caused by audio being active to 4000 times / second. This still causes a host cpu load of 50 % for simply playing audio, where as with this patch git master is at 13%, so we should backport this to 1.5 and 1.6 too. Note this will not apply to 1.5 and 1.6 as is. Cc: qemu-sta...@nongnu.org Signed-off-by: Hans de Goede hdego...@redhat.com --- audio/audio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/audio/audio.c b/audio/audio.c index af4cdf6..b3db679 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1124,7 +1124,8 @@ static int audio_is_timer_needed (void) static void audio_reset_timer (AudioState *s) { if (audio_is_timer_needed ()) { -timer_mod (s-ts, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 1); +timer_mod (s-ts, +qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + conf.period.ticks); This assumes conf.period.ticks is in nanoseconds. That seems wrong. Suggest multiplying by SCALE_US or SCALE_MS. Alex } else { timer_del (s-ts); -- 1.8.3.1 -- Alex Bligh
Re: [Qemu-devel] [PATCH 1/2] audio: honor QEMU_AUDIO_TIMER_PERIOD instead of waking up every *nano* second
Hi, On 10/10/2013 08:31 AM, Alex Bligh wrote: On 9 Oct 2013, at 20:42, Hans de Goede wrote: Now that we no longer have MIN_REARM_TIMER_NS a bug in the audio subsys has clearly shown it self by trying to make a timer fire every nano second. Note we have a similar problem in 1.6, 1.5 and older but there MIN_REARM_TIMER_NS limits the wakeups caused by audio being active to 4000 times / second. This still causes a host cpu load of 50 % for simply playing audio, where as with this patch git master is at 13%, so we should backport this to 1.5 and 1.6 too. Note this will not apply to 1.5 and 1.6 as is. Cc: qemu-sta...@nongnu.org Signed-off-by: Hans de Goede hdego...@redhat.com --- audio/audio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/audio/audio.c b/audio/audio.c index af4cdf6..b3db679 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1124,7 +1124,8 @@ static int audio_is_timer_needed (void) static void audio_reset_timer (AudioState *s) { if (audio_is_timer_needed ()) { -timer_mod (s-ts, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 1); +timer_mod (s-ts, +qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + conf.period.ticks); This assumes conf.period.ticks is in nanoseconds. That seems wrong. Suggest multiplying by SCALE_US or SCALE_MS. Which it is, quoting from higher up in the same file: conf.period.ticks = muldiv64 (1, get_ticks_per_sec (), conf.period.hertz); And get_ticks_per_sec () returns ns . Regards, Hans Alex } else { timer_del (s-ts); -- 1.8.3.1
Re: [Qemu-devel] [PATCH 1/2] audio: honor QEMU_AUDIO_TIMER_PERIOD instead of waking up every *nano* second
On 10 Oct 2013, at 07:58, Hans de Goede wrote: Which it is, quoting from higher up in the same file: conf.period.ticks = muldiv64 (1, get_ticks_per_sec (), conf.period.hertz); And get_ticks_per_sec () returns ns . Doh! I confused .hertz .ticks. -- Alex Bligh
[Qemu-devel] [PATCH] vmdk: implment bdrv_get_info and bdrv_get_specific_info
.bdrv_get_info reports cluster_size if it's a monolithic image. .bdrv_get_specific_info reports the image version (if applicable) and extent file name list. Signed-off-by: Fam Zheng f...@redhat.com --- block/vmdk.c | 44 qapi-schema.json | 14 +- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/block/vmdk.c b/block/vmdk.c index 5d56e31..ff9bdac 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1814,6 +1814,48 @@ static int vmdk_has_zero_init(BlockDriverState *bs) return 1; } +static int vmdk_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) +{ +BDRVVmdkState *s = bs-opaque; +/* Normally the cluster sizes for all the extents in a vmdk image are the + * same, but we don't bother to check for this here and only report the + * value for the monolithic case. */ +if (s-num_extents == 1 !s-extents[0].flat) { +bdi-cluster_size = s-extents[0].cluster_sectors * 512; +} +return 0; +} + +static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs) +{ +int i; +BDRVVmdkState *s = bs-opaque; +ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1); +strList **next; + +*spec_info = (ImageInfoSpecific){ +.kind = IMAGE_INFO_SPECIFIC_KIND_VMDK, +.vmdk = g_new(ImageInfoSpecificVmdk, 1), +}; + +next = spec_info-vmdk-extents; +for (i = 0; i s-num_extents; i++) { +*next = g_new(strList, 1); +**next = (strList){ +.value = g_strdup(s-extents[i].file-filename), +.next = NULL, +}; +next = (*next)-next; +} + +if (s-num_extents == 1) { +spec_info-vmdk-version = s-extents[0].version; +spec_info-vmdk-has_version = true; +} + +return spec_info; +} + static QEMUOptionParameter vmdk_create_options[] = { { .name = BLOCK_OPT_SIZE, @@ -1866,6 +1908,8 @@ static BlockDriver bdrv_vmdk = { .bdrv_co_get_block_status = vmdk_co_get_block_status, .bdrv_get_allocated_file_size = vmdk_get_allocated_file_size, .bdrv_has_zero_init = vmdk_has_zero_init, +.bdrv_get_info= vmdk_get_info, +.bdrv_get_specific_info = vmdk_get_specific_info, .create_options = vmdk_create_options, }; diff --git a/qapi-schema.json b/qapi-schema.json index a1a81a4..b1e74b3 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -225,6 +225,17 @@ } } ## +# @ImageInfoSpecificVmdk: +# +# Since: 1.7 +## +{ 'type': 'ImageInfoSpecificVmdk', + 'data': { + '*version': 'int', + 'extents': ['str'] + } } + +## # @ImageInfoSpecific: # # A discriminated record of image format specific information structures. @@ -234,7 +245,8 @@ { 'union': 'ImageInfoSpecific', 'data': { - 'qcow2': 'ImageInfoSpecificQCow2' + 'qcow2': 'ImageInfoSpecificQCow2', + 'vmdk': 'ImageInfoSpecificVmdk' } } ## -- 1.8.3.1
[Qemu-devel] [PATCH 1/2] vmdk: convert error reporting
Convert fprintf(stderr,... to error API by passing around errp to functions those want to report error message. There are 2 more fprintf(stderr,... remaining in read/write code path. Signed-off-by: Fam Zheng f...@redhat.com --- block/vmdk.c | 42 +- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 5d56e31..a98ad23 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -483,7 +483,7 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent) static int vmdk_open_vmfs_sparse(BlockDriverState *bs, BlockDriverState *file, - int flags) + int flags, Error **errp) { int ret; uint32_t magic; @@ -514,11 +514,11 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs, } static int vmdk_open_desc_file(BlockDriverState *bs, int flags, - uint64_t desc_offset); + uint64_t desc_offset, Error **errp); static int vmdk_open_vmdk4(BlockDriverState *bs, BlockDriverState *file, - int flags) + int flags, Error **errp) { int ret; uint32_t magic; @@ -534,7 +534,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, if (header.capacity == 0) { uint64_t desc_offset = le64_to_cpu(header.desc_offset); if (desc_offset) { -return vmdk_open_desc_file(bs, flags, desc_offset 9); +return vmdk_open_desc_file(bs, flags, desc_offset 9, errp); } } @@ -663,7 +663,7 @@ static int vmdk_parse_description(const char *desc, const char *opt_name, /* Open an extent file and append to bs array */ static int vmdk_open_sparse(BlockDriverState *bs, BlockDriverState *file, -int flags) +int flags, Error **errp) { uint32_t magic; @@ -674,10 +674,10 @@ static int vmdk_open_sparse(BlockDriverState *bs, magic = be32_to_cpu(magic); switch (magic) { case VMDK3_MAGIC: -return vmdk_open_vmfs_sparse(bs, file, flags); +return vmdk_open_vmfs_sparse(bs, file, flags, errp); break; case VMDK4_MAGIC: -return vmdk_open_vmdk4(bs, file, flags); +return vmdk_open_vmdk4(bs, file, flags, errp); break; default: return -EMEDIUMTYPE; @@ -686,7 +686,7 @@ static int vmdk_open_sparse(BlockDriverState *bs, } static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, -const char *desc_file_path) + const char *desc_file_path, Error **errp) { int ret; char access[11]; @@ -748,13 +748,13 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, extent-flat_start_offset = flat_offset 9; } else if (!strcmp(type, SPARSE) || !strcmp(type, VMFSSPARSE)) { /* SPARSE extent and VMFSSPARSE extent are both COWD sparse file*/ -ret = vmdk_open_sparse(bs, extent_file, bs-open_flags); +ret = vmdk_open_sparse(bs, extent_file, bs-open_flags, errp); if (ret) { bdrv_unref(extent_file); return ret; } } else { -fprintf(stderr, +error_setg(errp, VMDK: Not supported extent type \%s\.\n, type); return -ENOTSUP; } @@ -769,7 +769,7 @@ next_line: } static int vmdk_open_desc_file(BlockDriverState *bs, int flags, - uint64_t desc_offset) + uint64_t desc_offset, Error **errp) { int ret; char *buf = NULL; @@ -798,13 +798,13 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, strcmp(ct, vmfsSparse) strcmp(ct, twoGbMaxExtentSparse) strcmp(ct, twoGbMaxExtentFlat)) { -fprintf(stderr, +error_setg(errp, VMDK: Not supported image type \%s\.\n, ct); ret = -ENOTSUP; goto exit; } s-desc_offset = 0; -ret = vmdk_parse_extents(buf, bs, bs-file-filename); +ret = vmdk_parse_extents(buf, bs, bs-file-filename, errp); exit: g_free(buf); return ret; @@ -816,10 +816,10 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, int ret; BDRVVmdkState *s = bs-opaque; -if (vmdk_open_sparse(bs, bs-file, flags) == 0) { +if (vmdk_open_sparse(bs, bs-file, flags, errp) == 0) { s-desc_offset = 0x200; } else { -ret = vmdk_open_desc_file(bs, flags, 0); +ret = vmdk_open_desc_file(bs, flags, 0, errp); if (ret) { goto fail; } @@ -1517,12 +1517,12 @@ static int vmdk_create_extent(const char *filename, int64_t filesize, } static int
[Qemu-devel] [PATCH 2/2] vmdk: refuse enabling zeroed grain with flat images
This is a header flag and we needs sparse for the header. Signed-off-by: Fam Zheng f...@redhat.com --- block/vmdk.c | 4 1 file changed, 4 insertions(+) diff --git a/block/vmdk.c b/block/vmdk.c index a98ad23..78c0129 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1656,6 +1656,10 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options, error_setg(errp, flat image can't have backing file); return -ENOTSUP; } +if (flat zeroed_grain) { +error_setg(errp, flat image can't enable zeroed grain); +return -ENOTSUP; +} if (backing_file) { BlockDriverState *bs = bdrv_new(); ret = bdrv_open(bs, backing_file, NULL, 0, NULL, local_err); -- 1.8.3.1
[Qemu-devel] [PATCH v6 0/5] bugs fix for hpet
v6: move the setting of intcap to board, and keep the init value as zero. (thanks for the discussion from Paolo and Michael) introduce an extra hpet property compat to tell PC version v5: use stand compat property to fix hpet intcap on pc-q35, while on pc-piix, hard code intcap as IRQ2 v4: use stand compat property to fix hpet intcap v3: change hpet interrupt capablity on board's demand Liu Ping Fan (5): hpet: inverse polarity when pin above ISA_NUM_IRQS hpet: enable to entitle more irq pins for hpet PC: use qdev_xx to create hpet instead of sysbus_create_xx PC: add hpet compat to trace compatability version PC: differentiate hpet's interrupt capability on piix and q35 hw/i386/pc.c | 24 +--- hw/i386/pc_piix.c| 7 ++- hw/i386/pc_q35.c | 2 +- hw/timer/hpet.c | 24 include/hw/i386/pc.h | 11 ++- 5 files changed, 58 insertions(+), 10 deletions(-) -- 1.8.1.4
[Qemu-devel] [PATCH v6 1/5] hpet: inverse polarity when pin above ISA_NUM_IRQS
According to hpet spec, hpet irq is high active. But according to ICH spec, there is inversion before the input of ioapic. So the OS will expect low active on this IRQ line. (On bare metal, if OS driver claims high active on this line, spurious irq is generated) We fold the emulation of this inversion inside the hpet logic. Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com --- hw/timer/hpet.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index fcd22ae..8429eb3 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -198,13 +198,23 @@ static void update_irq(struct HPETTimer *timer, int set) if (!set || !timer_enabled(timer) || !hpet_enabled(timer-state)) { s-isr = ~mask; if (!timer_fsb_route(timer)) { -qemu_irq_lower(s-irqs[route]); +/* fold the ICH PIRQ# pin's internal inversion logic into hpet */ +if (route = ISA_NUM_IRQS) { +qemu_irq_raise(s-irqs[route]); +} else { +qemu_irq_lower(s-irqs[route]); +} } } else if (timer_fsb_route(timer)) { stl_le_phys(timer-fsb 32, timer-fsb 0x); } else if (timer-config HPET_TN_TYPE_LEVEL) { s-isr |= mask; -qemu_irq_raise(s-irqs[route]); +/* fold the ICH PIRQ# pin's internal inversion logic into hpet */ +if (route = ISA_NUM_IRQS) { +qemu_irq_lower(s-irqs[route]); +} else { +qemu_irq_raise(s-irqs[route]); +} } else { s-isr = ~mask; qemu_irq_pulse(s-irqs[route]); -- 1.8.1.4
[Qemu-devel] [PATCH v6 2/5] hpet: enable to entitle more irq pins for hpet
On q35, IRQ2/8 can be reserved for hpet timer 0/1. And pin 16~23 of ioapic can be dynamically assigned to hpet as guest chooses. So we introduce intcap property to do that. (currently, its value is IRQ2. Later, it should be set by board.) Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com --- hw/timer/hpet.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 8429eb3..5b11be4 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -25,6 +25,7 @@ */ #include hw/hw.h +#include hw/boards.h #include hw/i386/pc.h #include ui/console.h #include qemu/timer.h @@ -42,6 +43,9 @@ #define HPET_MSI_SUPPORT0 +/* Will fix: intcap is set by board, and should be 0 if nobody sets. */ +#define HPET_TN_INT_CAP_DEFAULT 0x4ULL + #define TYPE_HPET hpet #define HPET(obj) OBJECT_CHECK(HPETState, (obj), TYPE_HPET) @@ -73,6 +77,7 @@ typedef struct HPETState { uint8_t rtc_irq_level; qemu_irq pit_enabled; uint8_t num_timers; +uint32_t intcap; HPETTimer timer[HPET_MAX_TIMERS]; /* Memory-mapped, software visible registers */ @@ -663,8 +668,8 @@ static void hpet_reset(DeviceState *d) if (s-flags (1 HPET_MSI_SUPPORT)) { timer-config |= HPET_TN_FSB_CAP; } -/* advertise availability of ioapic inti2 */ -timer-config |= 0x0004ULL 32; +/* advertise availability of ioapic int */ +timer-config |= (uint64_t)s-intcap 32; timer-period = 0ULL; timer-wrap_flag = 0; } @@ -753,6 +758,7 @@ static void hpet_realize(DeviceState *dev, Error **errp) static Property hpet_device_properties[] = { DEFINE_PROP_UINT8(timers, HPETState, num_timers, HPET_MIN_TIMERS), DEFINE_PROP_BIT(msi, HPETState, flags, HPET_MSI_SUPPORT, false), +DEFINE_PROP_UINT32(intcap, HPETState, intcap, HPET_TN_INT_CAP_DEFAULT), DEFINE_PROP_END_OF_LIST(), }; -- 1.8.1.4
[Qemu-devel] [PATCH v6 5/5] PC: differentiate hpet's interrupt capability on piix and q35
For pc-piix-*, hpet's intcap is always hard coded as IRQ2. For q35, if it is pc-q35-1.7 and earlier, we use IRQ2 for compat reason, otherwise IRQ2, IRQ8, and IRQ16~23 are allowed. Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com --- hw/i386/pc.c | 21 - hw/i386/pc_piix.c| 3 ++- hw/i386/pc_q35.c | 2 +- include/hw/i386/pc.h | 3 ++- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f2b7b6c..062019d 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1219,7 +1219,8 @@ static const MemoryRegionOps ioportF0_io_ops = { void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, ISADevice **rtc_state, ISADevice **floppy, - bool no_vmport) + bool no_vmport, + bool hpet_irqs) { int i; DriveInfo *fd[MAX_FD]; @@ -1249,10 +1250,20 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, /* In order to set property, here not using sysbus_try_create_simple */ hpet = qdev_try_create(NULL, hpet); if (hpet) { -/* tmp fix. For compat, hard code to IRQ2 until we have correct - * compat property and differentiate pc-iix with pc-q35 - */ -qdev_prop_set_uint32(hpet, intcap, 0x4); +/* For pc-piix-*, hpet's intcap is always IRQ2. */ +if (!hpet_irqs) { +qdev_prop_set_uint32(hpet, intcap, 0x4); +} else { +/* For pc-q35-1.7 and earlier, use IRQ2 for compat. */ +uint8_t compat = object_property_get_int(OBJECT(hpet), +compat, NULL); +if (compat) { +qdev_prop_set_uint32(hpet, intcap, 0x4); +} else { +/* using IRQ16~23, IRQ8 and IRQ2 */ +qdev_prop_set_uint32(hpet, intcap, 0xff0104); +} +} qdev_init_nofail(hpet); sysbus_mmio_map(SYS_BUS_DEVICE(hpet), 0, HPET_BASE); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 90f1ea4..a45ce11 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -180,7 +180,8 @@ static void pc_init1(QEMUMachineInitArgs *args, pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL); /* init basic PC hardware */ -pc_basic_device_init(isa_bus, gsi, rtc_state, floppy, xen_enabled()); +pc_basic_device_init(isa_bus, gsi, rtc_state, floppy, xen_enabled(), +false); pc_nic_init(isa_bus, pci_bus); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index ca84e1c..9e41f4a 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -181,7 +181,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args) pc_register_ferr_irq(gsi[13]); /* init basic PC hardware */ -pc_basic_device_init(isa_bus, gsi, rtc_state, floppy, false); +pc_basic_device_init(isa_bus, gsi, rtc_state, floppy, false, true); /* connect pm stuff to lpc */ ich9_lpc_pm_init(lpc); diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 80aa7bd..a49d9cd 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -134,7 +134,8 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus); void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, ISADevice **rtc_state, ISADevice **floppy, - bool no_vmport); + bool no_vmport, + bool hpet_irqs); void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd); void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, const char *boot_device, -- 1.8.1.4
[Qemu-devel] [PATCH v6 3/5] PC: use qdev_xx to create hpet instead of sysbus_create_xx
sysbus_create_xx func does not allow us to set a device's extra properties. While hpet need to set its compat property before initialization, so we abandon the wrapper function, and spread its logic inline Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com --- hw/i386/pc.c| 11 +-- hw/timer/hpet.c | 4 +--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 0c313fe..f2b7b6c 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1246,9 +1246,16 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, * when the HPET wants to take over. Thus we have to disable the latter. */ if (!no_hpet (!kvm_irqchip_in_kernel() || kvm_has_pit_state2())) { -hpet = sysbus_try_create_simple(hpet, HPET_BASE, NULL); - +/* In order to set property, here not using sysbus_try_create_simple */ +hpet = qdev_try_create(NULL, hpet); if (hpet) { +/* tmp fix. For compat, hard code to IRQ2 until we have correct + * compat property and differentiate pc-iix with pc-q35 + */ +qdev_prop_set_uint32(hpet, intcap, 0x4); +qdev_init_nofail(hpet); +sysbus_mmio_map(SYS_BUS_DEVICE(hpet), 0, HPET_BASE); + for (i = 0; i GSI_NUM_PINS; i++) { sysbus_connect_irq(SYS_BUS_DEVICE(hpet), i, gsi[i]); } diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 5b11be4..69ce587 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -43,8 +43,6 @@ #define HPET_MSI_SUPPORT0 -/* Will fix: intcap is set by board, and should be 0 if nobody sets. */ -#define HPET_TN_INT_CAP_DEFAULT 0x4ULL #define TYPE_HPET hpet #define HPET(obj) OBJECT_CHECK(HPETState, (obj), TYPE_HPET) @@ -758,7 +756,7 @@ static void hpet_realize(DeviceState *dev, Error **errp) static Property hpet_device_properties[] = { DEFINE_PROP_UINT8(timers, HPETState, num_timers, HPET_MIN_TIMERS), DEFINE_PROP_BIT(msi, HPETState, flags, HPET_MSI_SUPPORT, false), -DEFINE_PROP_UINT32(intcap, HPETState, intcap, HPET_TN_INT_CAP_DEFAULT), +DEFINE_PROP_UINT32(intcap, HPETState, intcap, 0), DEFINE_PROP_END_OF_LIST(), }; -- 1.8.1.4
[Qemu-devel] [PATCH v6 4/5] PC: add hpet compat to trace compatability version
For guest bug compat, we need to limit hpet's intcap on IRQ2 for pc-q35-1.7 and earlier. We use hpet's compat property to indicate the PC version. Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index c6042c7..90f1ea4 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -346,6 +346,10 @@ static QEMUMachine pc_i440fx_machine_v1_7 = { .alias = pc, .init = pc_init_pci, .is_default = 1, +.compat_props = (GlobalProperty[]) { +PC_COMPAT_1_7, +{ /* end of list */ } +}, }; #define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index ca84e1c..569f946 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -270,6 +270,10 @@ static QEMUMachine pc_q35_machine_v1_7 = { .name = pc-q35-1.7, .alias = q35, .init = pc_q35_init, +.compat_props = (GlobalProperty[]) { +PC_COMPAT_1_7, +{ /* end of list */ } +}, }; #define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 69ce587..3cbe71e 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -76,6 +76,7 @@ typedef struct HPETState { qemu_irq pit_enabled; uint8_t num_timers; uint32_t intcap; +uint8_t compat; HPETTimer timer[HPET_MAX_TIMERS]; /* Memory-mapped, software visible registers */ @@ -757,6 +758,7 @@ static Property hpet_device_properties[] = { DEFINE_PROP_UINT8(timers, HPETState, num_timers, HPET_MIN_TIMERS), DEFINE_PROP_BIT(msi, HPETState, flags, HPET_MSI_SUPPORT, false), DEFINE_PROP_UINT32(intcap, HPETState, intcap, 0), +DEFINE_PROP_UINT8(compat, HPETState, compat, 0), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 9b2ddc4..80aa7bd 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -225,7 +225,15 @@ void pvpanic_init(ISABus *bus); int e820_add_entry(uint64_t, uint64_t, uint32_t); +#define PC_COMPAT_1_7 \ +{\ +.driver = hpet,\ +.property = compat,\ +.value= stringify(1),\ +} + #define PC_COMPAT_1_6 \ +PC_COMPAT_1_7, \ {\ .driver = e1000,\ .property = mitigation,\
[Qemu-devel] [PATCH 1/3] acpi: add interface to access user-installed tables
Also add a new API to install builtin tables, so that we can distinguish between the two. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- include/hw/acpi/acpi.h | 4 hw/acpi/core.c | 40 2 files changed, 44 insertions(+) diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h index 51733d3..6bbcb17 100644 --- a/include/hw/acpi/acpi.h +++ b/include/hw/acpi/acpi.h @@ -165,6 +165,10 @@ extern int acpi_enabled; extern char unsigned *acpi_tables; extern size_t acpi_tables_len; +uint8_t *acpi_table_first(void); +uint8_t *acpi_table_next(uint8_t *current); +unsigned acpi_table_len(void *current); void acpi_table_add(const QemuOpts *opts, Error **errp); +void acpi_table_add_builtin(const QemuOpts *opts, Error **errp); #endif /* !QEMU_HW_ACPI_H */ diff --git a/hw/acpi/core.c b/hw/acpi/core.c index 7467b88..4d25d8e 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -309,6 +309,46 @@ out: error_propagate(errp, err); } +static bool acpi_table_builtin = false; + +void acpi_table_add_builtin(const QemuOpts *opts, Error **errp) +{ +acpi_table_builtin = true; +acpi_table_add(opts, errp); +} + +unsigned acpi_table_len(void *current) +{ +struct acpi_table_header *hdr = current - sizeof(hdr-_length); +return hdr-_length; +} + +static +void *acpi_table_hdr(void *h) +{ +struct acpi_table_header *hdr = h; +return hdr-sig; +} + +uint8_t *acpi_table_first(void) +{ +if (acpi_table_builtin || !acpi_tables) { +return NULL; +} +return acpi_table_hdr(acpi_tables + ACPI_TABLE_PFX_SIZE); +} + +uint8_t *acpi_table_next(uint8_t *current) +{ +uint8_t *next = current + acpi_table_len(current); + +if (next - acpi_tables = acpi_tables_len) { +return NULL; +} else { +return acpi_table_hdr(next); +} +} + static void acpi_notify_wakeup(Notifier *notifier, void *data) { ACPIREGS *ar = container_of(notifier, ACPIREGS, wakeup); -- MST
[Qemu-devel] [PATCH 0/3] acpi-build: add -acpitable support
This small patchset is on top of my acpi series v9 - as that is very big by now, sending as incremental patches to simplify review. Michael S. Tsirkin (3): acpi: add interface to access user-installed tables pc: use new api to add builtin tables acpi-build: load tables supplied by user include/hw/acpi/acpi.h | 4 hw/acpi/core.c | 40 hw/i386/acpi-build.c | 9 + hw/i386/pc.c | 2 +- 4 files changed, 54 insertions(+), 1 deletion(-) -- MST
[Qemu-devel] [PATCH 2/3] pc: use new api to add builtin tables
At this point the only builtin table we have is the DSDT used for Q35. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- hw/i386/pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index a7fcbf9..a51f916 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1116,7 +1116,7 @@ void pc_acpi_init(const char *default_dsdt) opts = qemu_opts_parse(qemu_find_opts(acpi), arg, 0); g_assert(opts != NULL); -acpi_table_add(opts, err); +acpi_table_add_builtin(opts, err); if (err) { error_report(WARNING: failed to load %s: %s, filename, error_get_pretty(err)); -- MST
[Qemu-devel] [PATCH 3/3] acpi-build: load tables supplied by user
If user supplies any SSDTs using -acpi, install them in addition to the built-in ones. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- hw/i386/acpi-build.c | 9 + 1 file changed, 9 insertions(+) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 262d1d6..6cfa044 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1041,6 +1041,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) AcpiMiscInfo misc; AcpiMcfgInfo mcfg; PcPciInfo pci; +uint8_t *u; acpi_get_cpu_info(cpu); acpi_get_pm_info(pm); @@ -1092,6 +1093,14 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) build_mcfg_q35(tables-table_data, tables-linker, mcfg); } +/* Add tables supplied by user (if any) */ +for (u = acpi_table_first(); u; u = acpi_table_next(u)) { +unsigned len = acpi_table_len(u); + +acpi_add_table(table_offsets, tables-table_data); +g_array_append_vals(tables-table_data, u, len); +} + /* RSDT is pointed to by RSDP */ rsdt = tables-table_data-len; build_rsdt(tables-table_data, tables-linker, table_offsets); -- MST
Re: [Qemu-devel] [Bug 1100843] Re: Live Migration Causes Performance Issues
On 07.10.2013 11:55, Paolo Bonzini wrote: Il 07/10/2013 11:49, Peter Lieven ha scritto: It's in general not easy to do this if you take non-x86 targets into account. What about the dirty way to zero out all non zero pages at the beginning of ram_load? I'm not sure I follow? sth like this for each ram block at the beginning of ram_load. +base = memory_region_get_ram_ptr(block-mr); +for (offset = 0; offset block-length; + offset += TARGET_PAGE_SIZE) { +if (!is_zero_page(base + offset)) { +memset(base + offset, 0x00, TARGET_PAGE_SIZE); +} +} + Then add a capability skip_zero_pages which does not sent them on the source and enables this zeroing. it would also be possible to skip the zero check for each incoming compressed pages. Peter
[Qemu-devel] [PATCH 0/2] vmdk: convert error reporting
The first patch converts fprintf(stderr,... to error_setg with errp. The second patch checks the compatibility of zeroed_grain flag and flat type and reports error if both are true. Fam Zheng (2): vmdk: convert error reporting vmdk: refuse enabling zeroed grain with flat images block/vmdk.c | 46 +- 1 file changed, 25 insertions(+), 21 deletions(-) -- 1.8.3.1
Re: [Qemu-devel] An issue in block-migration
On Thu, Oct 03, 2013 at 04:23:45AM +, Yaodong Yang wrote: In block-migration.c file, line 435, if (bdrv_get_dirty(bmds-bs, sector)) { It looks like this if statement is used to check whether a chunk is dirty or not. If it is dirty, system will migrate a whole chunk, 1MB data, to the destination. Otherwise, the cur_dirty will increase by 1MB/512B sectors. However, in my understanding, this function, bdrv_get_dirty(bmds-bs, sector), only check this sector (512B) is dirty or not, rather than a whole chunk (1MB). Could someone tell me the reason? See block-migration.c:set_dirty_tracking(): bdrv_set_dirty_tracking(bmds-bs, enable ? BLOCK_SIZE : 0); The dirty bitmap granularity is set to BLOCK_SIZE. Any write in the open range [sector, sector + BLOCK_SIZE / BDRV_SECTOR_SIZE) will mark the bit dirty. Stefan
Re: [Qemu-devel] [PATCH 2/2] .gitmodules: use upstream SeaBIOS repo to fix submodule init
On Thu, Oct 03, 2013 at 06:06:15PM +0900, Peter Maydell wrote: On 3 October 2013 17:58, alex.ben...@linaro.org wrote: From: Alex Bennée a...@bennee.com Currently master is broken as the wanted commit doesn't exist in qemu's mirror of SeaBIOS. --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index d7e3f3c..d5d5417 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,7 +3,7 @@ url = git://git.qemu.org/vgabios.git/ [submodule roms/seabios] path = roms/seabios - url = git://git.qemu.org/seabios.git/ + url = git://git.seabios.org/seabios.git This is wrong. QEMU's submodules should all point to git.qemu.org. git.qemu-project.org is the preferred domain name. qemu.org is held by a third party. Last year there was a DNS outage that no core QEMU contributor could resolve because we don't have access to the DNS. Also, if the QEMU website IP address changes there may be a delay updating qemu.org. I will send patches to update the domain name. Stefan
[Qemu-devel] [PATCH 1/2] qcow2: Undo leaked allocations in co_writev
If the write request spans more than one L2 table, qcow2_alloc_cluster_offset cannot handle the required allocations atomically. This results in leaks if it allocated new clusters in any but the last L2 table touched and an error occurs in qcow2_co_writev before having established the L2 link. These non-atomic allocations were, however, indeed successful and are therefore given to the caller in the L2Meta list. If an error occurs in qcow2_co_writev and the L2Meta list is unwound, all its remaining entries are clusters whose L2 links were not yet established. Thus, all allocations in that list should be undone. Signed-off-by: Max Reitz mre...@redhat.com --- block/qcow2.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index b2489fb..6bedd5d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1017,6 +1017,13 @@ fail: while (l2meta != NULL) { QCowL2Meta *next; +/* Undo all leaked allocations */ +if (l2meta-nb_clusters != 0) { +qcow2_free_clusters(bs, l2meta-alloc_offset, +l2meta-nb_clusters s-cluster_bits, +QCOW2_DISCARD_ALWAYS); +} + if (l2meta-nb_clusters != 0) { QLIST_REMOVE(l2meta, next_in_flight); } -- 1.8.3.1
Re: [Qemu-devel] sniffing traffic between VMs
On Mon, Oct 07, 2013 at 05:47:46PM +0300, Alexander Binun wrote: Our first task is to trace the traffic between individual VMs and between VMs and the VMM (the KVM driver). So we are searching for proper places to insert sniffer code. We suspect that some functions in qemu/hw/virtio should be targeted. And we will appreciate any hints on this places. My blog post about -netdev pcap in QEMU is useful for QEMU network code development setups. But the simplest way to sniff traffic in a production x86 KVM configuration is using tcpdump on the host. The common networking setup on the host is a Linux software bridge (e.g. virbr0) and one tap device per guest (e.g. vm001-tap, vm002-tap). The tap devices are added to the bridge so guests can communicate with each other. When a guest sends a packet, the vhost_net host kernel driver injects the packet into the guest's tap device. The Linux network stack then hands the packet from the tap device to the bridge. The bridge will forward the packet as appropriate. In guest-guest communication this means the packet is forwarded to the destination guest's tap device. The vhost_net driver instance for the destination guest then reads the packet from its tap device and places it into the guest's virtio-net receive buffer. This configuration means you have 3 places where you can run tcpdump on the host: 1. On the source guest's tap device (e.g. vm001-tap). 2. On the bridge interface (e.g. virbr0). 3. On the destination guest's tap device (e.g. vm002-tap). There are other options too like using openvswitch or macvtap. Openvswitch might be interesting because I think it allows you to add filtering rules into the kernel and send packets that match the rules up to a userspace process for inspection. Stefan
Re: [Qemu-devel] [Bug 1236809] [NEW] qemu-system-x86_64 takes 100% CPU
On Tue, Oct 08, 2013 at 11:51:19AM -, chenlidong wrote: chenlidong@linux-0rsg:~/develop/qemu ps -ef | grep qemu root 19030 1 14 19:00 ?00:04:24 /usr/local/bin/qemu-system-x86_64 -name rhel6 -S -M pc-i440fx-1.6 -m 2048 -smp 1,sockets=1,cores=1,threads=1 -uuid 1925a96a-54b9-3c4a-dda0-6b42fdd0af2c -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/rhel6.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/libvirt/images/rhel6.img,if=none,id=drive-ide0-0-0,format=raw,cache=directsync -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=2 -drive if=none,id=drive-ide0-1-0,readonly=on,format=raw -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1 -netdev tap,fd=21,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:b3:b8:53,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -vga cirrus -device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 i used perf top, the result is below: Samples: 57K of event 'cycles', Event count (approx.): 26336443124 15.38% perf-22465.map [.] 0x7f143b99c9c6 5.90% qemu-system-x86_64 [.] phys_page_find 4.48% qemu-system-x86_64 [.] address_space_translate_internal 3.30% qemu-system-x86_64 [.] compute_all_subw 3.15% qemu-system-x86_64 [.] check_regs 2.56% qemu-system-x86_64 [.] tb_find_fast 2.34% qemu-system-x86_64 [.] tb_find_slow KVM is disabled - you are not using hardware virtualization extensions. Add -enable-kvm to the command-line or make sure libvirt is using kvm mode. Stefan
[Qemu-devel] [PATCH v2 3/6] qcow2: Add overlap-check options
Add runtime options to tune the overlap checks to be performed before write accesses. Signed-off-by: Max Reitz mre...@redhat.com --- block/qcow2.c | 46 ++ block/qcow2.h | 9 + 2 files changed, 55 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 199ebf2..1e29bc8 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -354,6 +354,52 @@ static QemuOptsList qcow2_runtime_opts = { .type = QEMU_OPT_BOOL, .help = Generate discard requests when other clusters are freed, }, +{ +.name = QCOW2_OPT_OVERLAP, +.type = QEMU_OPT_STRING, +.help = Selects which overlap checks to perform from a range of +templates (none, constant, cached, all), +}, +{ +.name = QCOW2_OPT_OVERLAP_MAIN_HEADER, +.type = QEMU_OPT_BOOL, +.help = Check for unintended writes into the main qcow2 header, +}, +{ +.name = QCOW2_OPT_OVERLAP_ACTIVE_L1, +.type = QEMU_OPT_BOOL, +.help = Check for unintended writes into the active L1 table, +}, +{ +.name = QCOW2_OPT_OVERLAP_ACTIVE_L2, +.type = QEMU_OPT_BOOL, +.help = Check for unintended writes into an active L2 table, +}, +{ +.name = QCOW2_OPT_OVERLAP_REFCOUNT_TABLE, +.type = QEMU_OPT_BOOL, +.help = Check for unintended writes into the refcount table, +}, +{ +.name = QCOW2_OPT_OVERLAP_REFCOUNT_BLOCK, +.type = QEMU_OPT_BOOL, +.help = Check for unintended writes into a refcount block, +}, +{ +.name = QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE, +.type = QEMU_OPT_BOOL, +.help = Check for unintended writes into the snapshot table, +}, +{ +.name = QCOW2_OPT_OVERLAP_INACTIVE_L1, +.type = QEMU_OPT_BOOL, +.help = Check for unintended writes into an inactive L1 table, +}, +{ +.name = QCOW2_OPT_OVERLAP_INACTIVE_L2, +.type = QEMU_OPT_BOOL, +.help = Check for unintended writes into an inactive L2 table, +}, { /* end of list */ } }, }; diff --git a/block/qcow2.h b/block/qcow2.h index 6c85bb9..28ccc4a 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -63,6 +63,15 @@ #define QCOW2_OPT_DISCARD_REQUEST pass-discard-request #define QCOW2_OPT_DISCARD_SNAPSHOT pass-discard-snapshot #define QCOW2_OPT_DISCARD_OTHER pass-discard-other +#define QCOW2_OPT_OVERLAP overlap-check +#define QCOW2_OPT_OVERLAP_MAIN_HEADER overlap-check.main-header +#define QCOW2_OPT_OVERLAP_ACTIVE_L1 overlap-check.active-l1 +#define QCOW2_OPT_OVERLAP_ACTIVE_L2 overlap-check.active-l2 +#define QCOW2_OPT_OVERLAP_REFCOUNT_TABLE overlap-check.refcount-table +#define QCOW2_OPT_OVERLAP_REFCOUNT_BLOCK overlap-check.refcount-block +#define QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE overlap-check.snapshot-table +#define QCOW2_OPT_OVERLAP_INACTIVE_L1 overlap-check.inactive-l1 +#define QCOW2_OPT_OVERLAP_INACTIVE_L2 overlap-check.inactive-l2 typedef struct QCowHeader { uint32_t magic; -- 1.8.3.1
[Qemu-devel] [PATCH v2 0/6] Configure metadata overlap checks at runtime
This series changes the way of selecting what metadata overlap checks to perform from (currently) using a macro to using a variable contained in BDRVQcowState which can be configured at runtime through several command line options. v2: - rebased on Kevin's block branch - patch 1: affects line numbers, diff environments and one overlap check that has been removed in the meantime - patch 2: line number changes - patch 5: replaced QCOW2_OL_SNAPSHOT_TABLE by QCOW2_OL_INACTIVE_L1 in the definition of QCOW2_OL_CACHED (the former one is already a part of QCOW2_OL_CONSTANT, the latter one was missing) Max Reitz (6): qcow2: Use negated overflow check mask qcow2: Make overlap check mask variable qcow2: Add overlap-check options qcow2: Array assigning options to OL check bits qcow2: Add more overlap check bitmask macros qcow2: Evaluate overlap check options block/qcow2-cache.c| 8 ++--- block/qcow2-cluster.c | 16 - block/qcow2-refcount.c | 22 ++-- block/qcow2-snapshot.c | 12 +++ block/qcow2.c | 91 -- block/qcow2.h | 30 + 6 files changed, 136 insertions(+), 43 deletions(-) -- 1.8.3.1
Re: [Qemu-devel] [PATCH v6 4/5] PC: add hpet compat to trace compatability version
Il 10/10/2013 09:56, Liu Ping Fan ha scritto: For guest bug compat, we need to limit hpet's intcap on IRQ2 for pc-q35-1.7 and earlier. We use hpet's compat property to indicate the PC version. Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index c6042c7..90f1ea4 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -346,6 +346,10 @@ static QEMUMachine pc_i440fx_machine_v1_7 = { .alias = pc, .init = pc_init_pci, .is_default = 1, +.compat_props = (GlobalProperty[]) { +PC_COMPAT_1_7, +{ /* end of list */ } +}, }; #define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index ca84e1c..569f946 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -270,6 +270,10 @@ static QEMUMachine pc_q35_machine_v1_7 = { .name = pc-q35-1.7, .alias = q35, .init = pc_q35_init, +.compat_props = (GlobalProperty[]) { +PC_COMPAT_1_7, +{ /* end of list */ } +}, }; #define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 69ce587..3cbe71e 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -76,6 +76,7 @@ typedef struct HPETState { qemu_irq pit_enabled; uint8_t num_timers; uint32_t intcap; +uint8_t compat; HPETTimer timer[HPET_MAX_TIMERS]; /* Memory-mapped, software visible registers */ @@ -757,6 +758,7 @@ static Property hpet_device_properties[] = { DEFINE_PROP_UINT8(timers, HPETState, num_timers, HPET_MIN_TIMERS), DEFINE_PROP_BIT(msi, HPETState, flags, HPET_MSI_SUPPORT, false), DEFINE_PROP_UINT32(intcap, HPETState, intcap, 0), +DEFINE_PROP_UINT8(compat, HPETState, compat, 0), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 9b2ddc4..80aa7bd 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -225,7 +225,15 @@ void pvpanic_init(ISABus *bus); int e820_add_entry(uint64_t, uint64_t, uint32_t); +#define PC_COMPAT_1_7 \ +{\ +.driver = hpet,\ +.property = compat,\ +.value= stringify(1),\ +} + #define PC_COMPAT_1_6 \ +PC_COMPAT_1_7, \ {\ .driver = e1000,\ .property = mitigation,\ You can set the intcap property directly instead of adding this indirection. Paolo
Re: [Qemu-devel] [PATCH v6 3/5] PC: use qdev_xx to create hpet instead of sysbus_create_xx
Il 10/10/2013 09:56, Liu Ping Fan ha scritto: sysbus_create_xx func does not allow us to set a device's extra properties. While hpet need to set its compat property before initialization, so we abandon the wrapper function, and spread its logic inline Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com --- hw/i386/pc.c| 11 +-- hw/timer/hpet.c | 4 +--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 0c313fe..f2b7b6c 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1246,9 +1246,16 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, * when the HPET wants to take over. Thus we have to disable the latter. */ if (!no_hpet (!kvm_irqchip_in_kernel() || kvm_has_pit_state2())) { -hpet = sysbus_try_create_simple(hpet, HPET_BASE, NULL); - +/* In order to set property, here not using sysbus_try_create_simple */ +hpet = qdev_try_create(NULL, hpet); if (hpet) { +/* tmp fix. For compat, hard code to IRQ2 until we have correct + * compat property and differentiate pc-iix with pc-q35 + */ +qdev_prop_set_uint32(hpet, intcap, 0x4); +qdev_init_nofail(hpet); +sysbus_mmio_map(SYS_BUS_DEVICE(hpet), 0, HPET_BASE); + for (i = 0; i GSI_NUM_PINS; i++) { sysbus_connect_irq(SYS_BUS_DEVICE(hpet), i, gsi[i]); } diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 5b11be4..69ce587 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -43,8 +43,6 @@ #define HPET_MSI_SUPPORT0 -/* Will fix: intcap is set by board, and should be 0 if nobody sets. */ -#define HPET_TN_INT_CAP_DEFAULT 0x4ULL #define TYPE_HPET hpet #define HPET(obj) OBJECT_CHECK(HPETState, (obj), TYPE_HPET) @@ -758,7 +756,7 @@ static void hpet_realize(DeviceState *dev, Error **errp) static Property hpet_device_properties[] = { DEFINE_PROP_UINT8(timers, HPETState, num_timers, HPET_MIN_TIMERS), DEFINE_PROP_BIT(msi, HPETState, flags, HPET_MSI_SUPPORT, false), -DEFINE_PROP_UINT32(intcap, HPETState, intcap, HPET_TN_INT_CAP_DEFAULT), +DEFINE_PROP_UINT32(intcap, HPETState, intcap, 0), DEFINE_PROP_END_OF_LIST(), }; This should not be needed anymore, except for changing the intcap default to 0 (which would go in patch 5). Paolo
[Qemu-devel] [PATCH v2 1/6] qcow2: Use negated overflow check mask
In qcow2_check_metadata_overlap and qcow2_pre_write_overlap_check, change the parameter signifying the checks to perform from its current positive form to a negative one, i.e., it will no longer explicitly specify every check to perform but rather a mask of checks not to perform. Signed-off-by: Max Reitz mre...@redhat.com --- block/qcow2-cache.c| 8 +++- block/qcow2-cluster.c | 16 +++- block/qcow2-refcount.c | 22 ++ block/qcow2-snapshot.c | 12 +--- block/qcow2.c | 5 ++--- block/qcow2.h | 4 ++-- 6 files changed, 29 insertions(+), 38 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 40a5a3f..8ecbb5b 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -115,15 +115,13 @@ static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i) } if (c == s-refcount_block_cache) { -ret = qcow2_pre_write_overlap_check(bs, -QCOW2_OL_DEFAULT ~QCOW2_OL_REFCOUNT_BLOCK, +ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_REFCOUNT_BLOCK, c-entries[i].offset, s-cluster_size); } else if (c == s-l2_table_cache) { -ret = qcow2_pre_write_overlap_check(bs, -QCOW2_OL_DEFAULT ~QCOW2_OL_ACTIVE_L2, +ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L2, c-entries[i].offset, s-cluster_size); } else { -ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT, +ret = qcow2_pre_write_overlap_check(bs, 0, c-entries[i].offset, s-cluster_size); } diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 0fd26bb..0348b97 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -83,8 +83,8 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, /* the L1 position has not yet been updated, so these clusters must * indeed be completely free */ -ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT, -new_l1_table_offset, new_l1_size2); +ret = qcow2_pre_write_overlap_check(bs, 0, new_l1_table_offset, +new_l1_size2); if (ret 0) { goto fail; } @@ -160,8 +160,7 @@ int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index) buf[i] = cpu_to_be64(s-l1_table[l1_start_index + i]); } -ret = qcow2_pre_write_overlap_check(bs, -QCOW2_OL_DEFAULT ~QCOW2_OL_ACTIVE_L1, +ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L1, s-l1_table_offset + 8 * l1_start_index, sizeof(buf)); if (ret 0) { return ret; @@ -396,7 +395,7 @@ static int coroutine_fn copy_sectors(BlockDriverState *bs, s-aes_encrypt_key); } -ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT, +ret = qcow2_pre_write_overlap_check(bs, 0, cluster_offset + n_start * BDRV_SECTOR_SIZE, n * BDRV_SECTOR_SIZE); if (ret 0) { goto out; @@ -1604,8 +1603,7 @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table, } } -ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT, -offset, s-cluster_size); +ret = qcow2_pre_write_overlap_check(bs, 0, offset, s-cluster_size); if (ret 0) { if (!preallocated) { qcow2_free_clusters(bs, offset, s-cluster_size, @@ -1661,8 +1659,8 @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table, } } else { if (l2_dirty) { -ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT -~(QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2), l2_offset, +ret = qcow2_pre_write_overlap_check(bs, +QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2, l2_offset, s-cluster_size); if (ret 0) { goto fail; diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 4ef6899..988644a 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1311,9 +1311,8 @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res, } if (l2_dirty) { -ret = qcow2_pre_write_overlap_check(bs, -QCOW2_OL_DEFAULT ~QCOW2_OL_ACTIVE_L2, l2_offset, -s-cluster_size); +ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L2, +l2_offset, s-cluster_size); if (ret 0) { fprintf(stderr, ERROR: Could not write L2 table; metadata overlap check failed: %s\n, strerror(-ret)); @@ -1354,8 +1353,7 @@ static int write_reftable_entry(BlockDriverState *bs, int rt_index)
[Qemu-devel] [PATCH v2 5/6] qcow2: Add more overlap check bitmask macros
Introduces the macros QCOW2_OL_CONSTANT and QCOW2_OL_ALL in addition to the already existing QCOW2_OL_CACHED, signifying all metadata overlap checks that can be performed in constant time (regardless of image size etc.) and truly all available overlap checks, respectively. Signed-off-by: Max Reitz mre...@redhat.com --- block/qcow2.h | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 28ccc4a..922e190 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -326,11 +326,19 @@ typedef enum QCow2MetadataOverlap { QCOW2_OL_INACTIVE_L2= (1 QCOW2_OL_INACTIVE_L2_BITNR), } QCow2MetadataOverlap; +/* Perform all overlap checks which can be done in constant time */ +#define QCOW2_OL_CONSTANT \ +(QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 | QCOW2_OL_REFCOUNT_TABLE | \ + QCOW2_OL_SNAPSHOT_TABLE) + /* Perform all overlap checks which don't require disk access */ #define QCOW2_OL_CACHED \ -(QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 | QCOW2_OL_ACTIVE_L2 | \ - QCOW2_OL_REFCOUNT_TABLE | QCOW2_OL_REFCOUNT_BLOCK | \ - QCOW2_OL_SNAPSHOT_TABLE | QCOW2_OL_INACTIVE_L1) +(QCOW2_OL_CONSTANT | QCOW2_OL_ACTIVE_L2 | QCOW2_OL_REFCOUNT_BLOCK | \ + QCOW2_OL_INACTIVE_L1) + +/* Perform all overlap checks */ +#define QCOW2_OL_ALL \ +(QCOW2_OL_CACHED | QCOW2_OL_INACTIVE_L2) #define L1E_OFFSET_MASK 0x0000ULL #define L2E_OFFSET_MASK 0x0000ULL -- 1.8.3.1
Re: [Qemu-devel] [PATCH v6 2/5] hpet: enable to entitle more irq pins for hpet
Il 10/10/2013 09:56, Liu Ping Fan ha scritto: On q35, IRQ2/8 can be reserved for hpet timer 0/1. And pin 16~23 of ioapic can be dynamically assigned to hpet as guest chooses. So we introduce intcap property to do that. (currently, its value is IRQ2. Later, it should be set by board.) Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com --- hw/timer/hpet.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 8429eb3..5b11be4 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -25,6 +25,7 @@ */ #include hw/hw.h +#include hw/boards.h #include hw/i386/pc.h #include ui/console.h #include qemu/timer.h @@ -42,6 +43,9 @@ #define HPET_MSI_SUPPORT0 +/* Will fix: intcap is set by board, and should be 0 if nobody sets. */ +#define HPET_TN_INT_CAP_DEFAULT 0x4ULL + #define TYPE_HPET hpet #define HPET(obj) OBJECT_CHECK(HPETState, (obj), TYPE_HPET) @@ -73,6 +77,7 @@ typedef struct HPETState { uint8_t rtc_irq_level; qemu_irq pit_enabled; uint8_t num_timers; +uint32_t intcap; HPETTimer timer[HPET_MAX_TIMERS]; /* Memory-mapped, software visible registers */ @@ -663,8 +668,8 @@ static void hpet_reset(DeviceState *d) if (s-flags (1 HPET_MSI_SUPPORT)) { timer-config |= HPET_TN_FSB_CAP; } -/* advertise availability of ioapic inti2 */ -timer-config |= 0x0004ULL 32; +/* advertise availability of ioapic int */ +timer-config |= (uint64_t)s-intcap 32; timer-period = 0ULL; timer-wrap_flag = 0; } @@ -753,6 +758,7 @@ static void hpet_realize(DeviceState *dev, Error **errp) static Property hpet_device_properties[] = { DEFINE_PROP_UINT8(timers, HPETState, num_timers, HPET_MIN_TIMERS), DEFINE_PROP_BIT(msi, HPETState, flags, HPET_MSI_SUPPORT, false), +DEFINE_PROP_UINT32(intcap, HPETState, intcap, HPET_TN_INT_CAP_DEFAULT), DEFINE_PROP_END_OF_LIST(), }; According to Michael's request, a zero intcap should be detected in hpet_realize and give an error. Paolo
[Qemu-devel] [PATCH v2 6/6] qcow2: Evaluate overlap check options
Evaluate the runtime overlap check options and set BDRVQcowState.overlap_check appropriately. Signed-off-by: Max Reitz mre...@redhat.com --- block/qcow2.c | 29 - 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index eb17c2a..13e34f0 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -425,6 +425,8 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, Error *local_err = NULL; uint64_t ext_end; uint64_t l1_vm_state_index; +const char *opt_overlap_check; +int overlap_check_template = 0; ret = bdrv_pread(bs-file, 0, header, sizeof(header)); if (ret 0) { @@ -688,7 +690,32 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, s-discard_passthrough[QCOW2_DISCARD_OTHER] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); -s-overlap_check = QCOW2_OL_CACHED; +opt_overlap_check = qemu_opt_get(opts, overlap-check) ?: cached; +if (!strcmp(opt_overlap_check, none)) { +overlap_check_template = 0; +} else if (!strcmp(opt_overlap_check, constant)) { +overlap_check_template = QCOW2_OL_CONSTANT; +} else if (!strcmp(opt_overlap_check, cached)) { +overlap_check_template = QCOW2_OL_CACHED; +} else if (!strcmp(opt_overlap_check, all)) { +overlap_check_template = QCOW2_OL_ALL; +} else { +error_setg(errp, Unsupported value '%s' for qcow2 option + 'overlap-check'. Allowed are either of the following: + none, constant, cached, all, opt_overlap_check); +qemu_opts_del(opts); +ret = -EINVAL; +goto fail; +} + +s-overlap_check = 0; +for (i = 0; i QCOW2_OL_MAX_BITNR; i++) { +/* overlap-check defines a template bitmask, but every flag may be + * overwritten through the associated boolean option */ +s-overlap_check |= +qemu_opt_get_bool(opts, overlap_bool_option_names[i], + overlap_check_template (1 i)) i; +} qemu_opts_del(opts); -- 1.8.3.1
Re: [Qemu-devel] [PATCH v6 2/5] hpet: enable to entitle more irq pins for hpet
On Thu, Oct 10, 2013 at 03:56:16PM +0800, Liu Ping Fan wrote: On q35, IRQ2/8 can be reserved for hpet timer 0/1. And pin 16~23 of ioapic can be dynamically assigned to hpet as guest chooses. So we introduce intcap property to do that. (currently, its value is IRQ2. Later, it should be set by board.) Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com --- hw/timer/hpet.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 8429eb3..5b11be4 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -25,6 +25,7 @@ */ #include hw/hw.h +#include hw/boards.h #include hw/i386/pc.h #include ui/console.h #include qemu/timer.h @@ -42,6 +43,9 @@ #define HPET_MSI_SUPPORT0 +/* Will fix: intcap is set by board, and should be 0 if nobody sets. */ +#define HPET_TN_INT_CAP_DEFAULT 0x4ULL + #define TYPE_HPET hpet #define HPET(obj) OBJECT_CHECK(HPETState, (obj), TYPE_HPET) @@ -73,6 +77,7 @@ typedef struct HPETState { uint8_t rtc_irq_level; qemu_irq pit_enabled; uint8_t num_timers; +uint32_t intcap; HPETTimer timer[HPET_MAX_TIMERS]; /* Memory-mapped, software visible registers */ @@ -663,8 +668,8 @@ static void hpet_reset(DeviceState *d) if (s-flags (1 HPET_MSI_SUPPORT)) { timer-config |= HPET_TN_FSB_CAP; } -/* advertise availability of ioapic inti2 */ -timer-config |= 0x0004ULL 32; +/* advertise availability of ioapic int */ +timer-config |= (uint64_t)s-intcap 32; timer-period = 0ULL; timer-wrap_flag = 0; } @@ -753,6 +758,7 @@ static void hpet_realize(DeviceState *dev, Error **errp) static Property hpet_device_properties[] = { DEFINE_PROP_UINT8(timers, HPETState, num_timers, HPET_MIN_TIMERS), DEFINE_PROP_BIT(msi, HPETState, flags, HPET_MSI_SUPPORT, false), +DEFINE_PROP_UINT32(intcap, HPETState, intcap, HPET_TN_INT_CAP_DEFAULT), DEFINE_PROP_END_OF_LIST(), }; Please add a macro for this name as you use it in other files later. -- 1.8.1.4
Re: [Qemu-devel] [Nbd] Hibernate and qemu-nbd
On Fri, Oct 04, 2013 at 07:30:45AM -0700, Mark Trumpold wrote: On 9/26/13 10:18 PM, Stefan Hajnoczi stefa...@gmail.com wrote: Try the qemu-nbd --persistent option. That should prevent it from shutting down when nbd-client is disconnected. Stefan Hi Stefan, Sorry for the delay.. I tried the following per your suggestion: 920 qemu-nbd --persistent -p 2000 /root/qemu/q1.img 921 nbd-client -persist localhost 2000 /dev/nbd0 922 fsck /dev/nbd0 923 mount /dev/nbd0 /mnt 924 ls /mnt 925 umount /dev/nbd0 :: 927 echo reboot /sys/power/disk 928 echo disk /sys/power/state 929 mount /dev/nbd0 /mnt This seems to work; that is both sides (client and server) persist after the hibernate cycle. However, if I don't 'umount' '/dev/nbd0' before the hibernate cycle, and try to 'ls /mnt' after, the 'ls' hangs indefinitely. For my real use case we have the root filesystem mounted, so unmounting is not an option (at least I don't think so). I also tried remounting readonly, and also 'blockdev --flushbufs ..' before the hibernate cycle -- either or both did not help. I had thought about trying a 'chroot' and then a 'umount', but have not yet tried this. This one was so close.. Too bad. I'm sure it's solvable but would require more debugging and writing qemu-nbd.c and kernel nbd.c fixes. Unfortunately I don't have time to look into it myself. Stefan
Re: [Qemu-devel] [PATCH v6 5/5] PC: differentiate hpet's interrupt capability on piix and q35
On Thu, Oct 10, 2013 at 03:56:19PM +0800, Liu Ping Fan wrote: For pc-piix-*, hpet's intcap is always hard coded as IRQ2. For q35, if it is pc-q35-1.7 and earlier, we use IRQ2 for compat reason, otherwise IRQ2, IRQ8, and IRQ16~23 are allowed. Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com --- hw/i386/pc.c | 21 - hw/i386/pc_piix.c| 3 ++- hw/i386/pc_q35.c | 2 +- include/hw/i386/pc.h | 3 ++- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f2b7b6c..062019d 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1219,7 +1219,8 @@ static const MemoryRegionOps ioportF0_io_ops = { void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, ISADevice **rtc_state, ISADevice **floppy, - bool no_vmport) + bool no_vmport, + bool hpet_irqs) { int i; DriveInfo *fd[MAX_FD]; @@ -1249,10 +1250,20 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, /* In order to set property, here not using sysbus_try_create_simple */ hpet = qdev_try_create(NULL, hpet); if (hpet) { -/* tmp fix. For compat, hard code to IRQ2 until we have correct - * compat property and differentiate pc-iix with pc-q35 - */ -qdev_prop_set_uint32(hpet, intcap, 0x4); +/* For pc-piix-*, hpet's intcap is always IRQ2. */ +if (!hpet_irqs) { +qdev_prop_set_uint32(hpet, intcap, 0x4); +} else { +/* For pc-q35-1.7 and earlier, use IRQ2 for compat. */ +uint8_t compat = object_property_get_int(OBJECT(hpet), +compat, NULL); +if (compat) { +qdev_prop_set_uint32(hpet, intcap, 0x4); +} else { +/* using IRQ16~23, IRQ8 and IRQ2 */ +qdev_prop_set_uint32(hpet, intcap, 0xff0104); +} +} So why do we need an extra property? uint8_t compat = object_property_get_int(OBJECT(hpet), intcap, NULL); if (!intcap) { /* For pc-piix-*, hpet's intcap is IRQ2. */ /* For Q35, using IRQ16~23, IRQ8 and IRQ2 */ uint32_t intcap = hpet_irqs ? 0xff0104 : 0x4; qdev_prop_set_uint32(hpet, intcap, intcap); } now all you need to do for compat is set intcap property. qdev_init_nofail(hpet); sysbus_mmio_map(SYS_BUS_DEVICE(hpet), 0, HPET_BASE); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 90f1ea4..a45ce11 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -180,7 +180,8 @@ static void pc_init1(QEMUMachineInitArgs *args, pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL); /* init basic PC hardware */ -pc_basic_device_init(isa_bus, gsi, rtc_state, floppy, xen_enabled()); +pc_basic_device_init(isa_bus, gsi, rtc_state, floppy, xen_enabled(), +false); pc_nic_init(isa_bus, pci_bus); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index ca84e1c..9e41f4a 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -181,7 +181,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args) pc_register_ferr_irq(gsi[13]); /* init basic PC hardware */ -pc_basic_device_init(isa_bus, gsi, rtc_state, floppy, false); +pc_basic_device_init(isa_bus, gsi, rtc_state, floppy, false, true); /* connect pm stuff to lpc */ ich9_lpc_pm_init(lpc); diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 80aa7bd..a49d9cd 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -134,7 +134,8 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus); void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, ISADevice **rtc_state, ISADevice **floppy, - bool no_vmport); + bool no_vmport, + bool hpet_irqs); void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd); void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, const char *boot_device, -- 1.8.1.4
Re: [Qemu-devel] [PATCH v6 3/5] PC: use qdev_xx to create hpet instead of sysbus_create_xx
On Thu, Oct 10, 2013 at 03:56:17PM +0800, Liu Ping Fan wrote: sysbus_create_xx func does not allow us to set a device's extra properties. While hpet need to set its compat property before initialization, so we abandon the wrapper function, and spread its logic inline Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com I would merge patches 3,4,5 together. It's generally not a good idea to change same line of code in multiple patches in a patchset, makes review harder instead of easier. --- hw/i386/pc.c| 11 +-- hw/timer/hpet.c | 4 +--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 0c313fe..f2b7b6c 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1246,9 +1246,16 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, * when the HPET wants to take over. Thus we have to disable the latter. */ if (!no_hpet (!kvm_irqchip_in_kernel() || kvm_has_pit_state2())) { -hpet = sysbus_try_create_simple(hpet, HPET_BASE, NULL); - +/* In order to set property, here not using sysbus_try_create_simple */ +hpet = qdev_try_create(NULL, hpet); if (hpet) { +/* tmp fix. For compat, hard code to IRQ2 until we have correct + * compat property and differentiate pc-iix with pc-q35 + */ +qdev_prop_set_uint32(hpet, intcap, 0x4); +qdev_init_nofail(hpet); +sysbus_mmio_map(SYS_BUS_DEVICE(hpet), 0, HPET_BASE); + for (i = 0; i GSI_NUM_PINS; i++) { sysbus_connect_irq(SYS_BUS_DEVICE(hpet), i, gsi[i]); } diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 5b11be4..69ce587 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -43,8 +43,6 @@ #define HPET_MSI_SUPPORT0 -/* Will fix: intcap is set by board, and should be 0 if nobody sets. */ -#define HPET_TN_INT_CAP_DEFAULT 0x4ULL #define TYPE_HPET hpet #define HPET(obj) OBJECT_CHECK(HPETState, (obj), TYPE_HPET) @@ -758,7 +756,7 @@ static void hpet_realize(DeviceState *dev, Error **errp) static Property hpet_device_properties[] = { DEFINE_PROP_UINT8(timers, HPETState, num_timers, HPET_MIN_TIMERS), DEFINE_PROP_BIT(msi, HPETState, flags, HPET_MSI_SUPPORT, false), -DEFINE_PROP_UINT32(intcap, HPETState, intcap, HPET_TN_INT_CAP_DEFAULT), +DEFINE_PROP_UINT32(intcap, HPETState, intcap, 0), DEFINE_PROP_END_OF_LIST(), }; -- 1.8.1.4
Re: [Qemu-devel] [PATCH 1/2] audio: honor QEMU_AUDIO_TIMER_PERIOD instead of waking up every *nano* second
Hi, On 9 Oct 2013, at 20:42, Hans de Goede wrote: Now that we no longer have MIN_REARM_TIMER_NS a bug in the audio subsys has clearly shown it self by trying to make a timer fire every nano second. Note we have a similar problem in 1.6, 1.5 and older but there MIN_REARM_TIMER_NS limits the wakeups caused by audio being active to 4000 times / second. This still causes a host cpu load of 50 % for simply playing audio, where as with this patch git master is at 13%, so we should backport this to 1.5 and 1.6 too. I'm still not sure when this actually started happening, but looking at RHEL-6 qemu sources to see if that has the issue too, I've learned how this problem was introduced, the audio_timer callback used to do this: qemu_mod_timer (s-ts, qemu_get_clock (vm_clock) + conf.period.ticks); instead of calling audio_reset_timer(), so in the past there were 2 mod_timer calls, one from audio_reset_timer(), which scheduled the callback to run ASAP, and one from the audio_timer callback honering conf.period.hertz. Then at some point the qemu_mod_timer call in audio_timer was replaced with calling audio_reset_timer() and we got the problem my patch fixes. Regards, Hans
[Qemu-devel] [PATCH 2/2] qemu-iotests: Extend test 026
Extend test case 026 by an aio_write fail test, which should not result in any leaked clusters. Signed-off-by: Max Reitz mre...@redhat.com --- tests/qemu-iotests/026 | 31 +++ tests/qemu-iotests/026.out | 8 tests/qemu-iotests/026.out.nocache | 8 3 files changed, 47 insertions(+) diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026 index ebe29d0..a9dfe36 100755 --- a/tests/qemu-iotests/026 +++ b/tests/qemu-iotests/026 @@ -193,6 +193,37 @@ done done done +echo +echo === Write leak test === +echo +CLUSTER_SIZE=512 + +for event in write_aio; do +for errno in 28; do +for imm in off; do +for once in on; do + +cat $TEST_DIR/blkdebug.conf EOF +[inject-error] +event = $event +errno = $errno +immediately = $imm +once = $once +EOF + +_make_test_img 1G + +echo +echo Event: $event; errno: $errno; imm: $imm; once: $once +$QEMU_IO -c write 0 128k $BLKDBG_TEST_IMG | _filter_qemu_io + +_check_test_img 21 | grep -v refcount=1 reference=0 + +done +done +done +done + # success, all done echo *** done rm -f $seq.full diff --git a/tests/qemu-iotests/026.out b/tests/qemu-iotests/026.out index 1504579..c94daca 100644 --- a/tests/qemu-iotests/026.out +++ b/tests/qemu-iotests/026.out @@ -599,4 +599,12 @@ write failed: No space left on device 96 leaked clusters were found on the image. This means waste of disk space, but no harm to data. + +=== Write leak test === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 + +Event: write_aio; errno: 28; imm: off; once: on +write failed: No space left on device +No errors were found on the image. *** done diff --git a/tests/qemu-iotests/026.out.nocache b/tests/qemu-iotests/026.out.nocache index c9d242e..962bb71 100644 --- a/tests/qemu-iotests/026.out.nocache +++ b/tests/qemu-iotests/026.out.nocache @@ -607,4 +607,12 @@ write failed: No space left on device 96 leaked clusters were found on the image. This means waste of disk space, but no harm to data. + +=== Write leak test === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 + +Event: write_aio; errno: 28; imm: off; once: on +write failed: No space left on device +No errors were found on the image. *** done -- 1.8.3.1
[Qemu-devel] [PATCH v2 2/6] qcow2: Make overlap check mask variable
Replace the QCOW2_OL_DEFAULT macro by a variable overlap_check in BDRVQcowState. Signed-off-by: Max Reitz mre...@redhat.com --- block/qcow2-refcount.c | 2 +- block/qcow2.c | 2 ++ block/qcow2.h | 5 ++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 988644a..1ff43d0 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1649,7 +1649,7 @@ int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset, int64_t size) { BDRVQcowState *s = bs-opaque; -int chk = QCOW2_OL_DEFAULT ~ign; +int chk = s-overlap_check ~ign; int i, j; if (!size) { diff --git a/block/qcow2.c b/block/qcow2.c index 28dc560..199ebf2 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -631,6 +631,8 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, s-discard_passthrough[QCOW2_DISCARD_OTHER] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); +s-overlap_check = QCOW2_OL_CACHED; + qemu_opts_del(opts); if (s-use_lazy_refcounts s-qcow_version 3) { diff --git a/block/qcow2.h b/block/qcow2.h index 8692011..6c85bb9 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -203,6 +203,8 @@ typedef struct BDRVQcowState { bool discard_passthrough[QCOW2_DISCARD_MAX]; +int overlap_check; /* bitmask of Qcow2MetadataOverlap values */ + uint64_t incompatible_features; uint64_t compatible_features; uint64_t autoclear_features; @@ -321,9 +323,6 @@ typedef enum QCow2MetadataOverlap { QCOW2_OL_REFCOUNT_TABLE | QCOW2_OL_REFCOUNT_BLOCK | \ QCOW2_OL_SNAPSHOT_TABLE | QCOW2_OL_INACTIVE_L1) -/* The default checks to perform */ -#define QCOW2_OL_DEFAULT QCOW2_OL_CACHED - #define L1E_OFFSET_MASK 0x0000ULL #define L2E_OFFSET_MASK 0x0000ULL #define L2E_COMPRESSED_OFFSET_SIZE_MASK 0x3fffULL -- 1.8.3.1
[Qemu-devel] NBD support for mingw32 (windows)
Hi, This patch adds support for NBD under mingw32. It contains a small hack with the use of Sleep(). signed-off-by: Goshen, OrX orx.gos...@intel.commailto:orx.gos...@intel.com, Ocheretny, Pavel pavel.ochere...@intel.commailto:pavel.ochere...@intel.com (As part of a work at Intel CORP) - Intel Electronics Ltd. This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. nbd support.patch Description: nbd support.patch
Re: [Qemu-devel] [PATCH v6 2/5] hpet: enable to entitle more irq pins for hpet
Il 10/10/2013 11:16, Michael S. Tsirkin ha scritto: On Thu, Oct 10, 2013 at 03:56:16PM +0800, Liu Ping Fan wrote: On q35, IRQ2/8 can be reserved for hpet timer 0/1. And pin 16~23 of ioapic can be dynamically assigned to hpet as guest chooses. So we introduce intcap property to do that. (currently, its value is IRQ2. Later, it should be set by board.) Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com --- hw/timer/hpet.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 8429eb3..5b11be4 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -25,6 +25,7 @@ */ #include hw/hw.h +#include hw/boards.h #include hw/i386/pc.h #include ui/console.h #include qemu/timer.h @@ -42,6 +43,9 @@ #define HPET_MSI_SUPPORT0 +/* Will fix: intcap is set by board, and should be 0 if nobody sets. */ +#define HPET_TN_INT_CAP_DEFAULT 0x4ULL + #define TYPE_HPET hpet #define HPET(obj) OBJECT_CHECK(HPETState, (obj), TYPE_HPET) @@ -73,6 +77,7 @@ typedef struct HPETState { uint8_t rtc_irq_level; qemu_irq pit_enabled; uint8_t num_timers; +uint32_t intcap; HPETTimer timer[HPET_MAX_TIMERS]; /* Memory-mapped, software visible registers */ @@ -663,8 +668,8 @@ static void hpet_reset(DeviceState *d) if (s-flags (1 HPET_MSI_SUPPORT)) { timer-config |= HPET_TN_FSB_CAP; } -/* advertise availability of ioapic inti2 */ -timer-config |= 0x0004ULL 32; +/* advertise availability of ioapic int */ +timer-config |= (uint64_t)s-intcap 32; timer-period = 0ULL; timer-wrap_flag = 0; } @@ -753,6 +758,7 @@ static void hpet_realize(DeviceState *dev, Error **errp) static Property hpet_device_properties[] = { DEFINE_PROP_UINT8(timers, HPETState, num_timers, HPET_MIN_TIMERS), DEFINE_PROP_BIT(msi, HPETState, flags, HPET_MSI_SUPPORT, false), +DEFINE_PROP_UINT32(intcap, HPETState, intcap, HPET_TN_INT_CAP_DEFAULT), DEFINE_PROP_END_OF_LIST(), }; Please add a macro for this name as you use it in other files later. Are you sure? This is not done for any other compat property. Paolo
[Qemu-devel] [PATCH v2 4/6] qcow2: Array assigning options to OL check bits
Add an array which assigns the option string to its corresponding overlap check bit. Signed-off-by: Max Reitz mre...@redhat.com --- block/qcow2.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 1e29bc8..eb17c2a 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -404,6 +404,17 @@ static QemuOptsList qcow2_runtime_opts = { }, }; +static const char *overlap_bool_option_names[QCOW2_OL_MAX_BITNR] = { +[QCOW2_OL_MAIN_HEADER_BITNR]= QCOW2_OPT_OVERLAP_MAIN_HEADER, +[QCOW2_OL_ACTIVE_L1_BITNR] = QCOW2_OPT_OVERLAP_ACTIVE_L1, +[QCOW2_OL_ACTIVE_L2_BITNR] = QCOW2_OPT_OVERLAP_ACTIVE_L2, +[QCOW2_OL_REFCOUNT_TABLE_BITNR] = QCOW2_OPT_OVERLAP_REFCOUNT_TABLE, +[QCOW2_OL_REFCOUNT_BLOCK_BITNR] = QCOW2_OPT_OVERLAP_REFCOUNT_BLOCK, +[QCOW2_OL_SNAPSHOT_TABLE_BITNR] = QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE, +[QCOW2_OL_INACTIVE_L1_BITNR]= QCOW2_OPT_OVERLAP_INACTIVE_L1, +[QCOW2_OL_INACTIVE_L2_BITNR]= QCOW2_OPT_OVERLAP_INACTIVE_L2, +}; + static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { -- 1.8.3.1
Re: [Qemu-devel] [PATCH 1/2] audio: honor QEMU_AUDIO_TIMER_PERIOD instead of waking up every *nano* second
Il 10/10/2013 11:23, Hans de Goede ha scritto: Hi, On 9 Oct 2013, at 20:42, Hans de Goede wrote: Now that we no longer have MIN_REARM_TIMER_NS a bug in the audio subsys has clearly shown it self by trying to make a timer fire every nano second. Note we have a similar problem in 1.6, 1.5 and older but there MIN_REARM_TIMER_NS limits the wakeups caused by audio being active to 4000 times / second. This still causes a host cpu load of 50 % for simply playing audio, where as with this patch git master is at 13%, so we should backport this to 1.5 and 1.6 too. I'm still not sure when this actually started happening, but looking at RHEL-6 qemu sources to see if that has the issue too, I've learned how this problem was introduced, the audio_timer callback used to do this: qemu_mod_timer (s-ts, qemu_get_clock (vm_clock) + conf.period.ticks); instead of calling audio_reset_timer(), so in the past there were 2 mod_timer calls, one from audio_reset_timer(), which scheduled the callback to run ASAP, and one from the audio_timer callback honering conf.period.hertz. Then at some point the qemu_mod_timer call in audio_timer was replaced with calling audio_reset_timer() and we got the problem my patch fixes. The first broken version seems to be 0.14.0: commit 39deb1e496de81957167daebf5cf5d1fbd5e47c2 Author: malc av1...@comtv.ru Date: Thu Nov 18 14:30:12 2010 +0300 audio: Only use audio timer when necessary Originally proposed by Gerd Hoffmann. Signed-off-by: malc av1...@comtv.ru Acked-by: Gerd Hoffmann kra...@redhat.com
Re: [Qemu-devel] [PATCH v6 2/5] hpet: enable to entitle more irq pins for hpet
On Thu, Oct 10, 2013 at 11:33:07AM +0200, Paolo Bonzini wrote: Il 10/10/2013 11:16, Michael S. Tsirkin ha scritto: On Thu, Oct 10, 2013 at 03:56:16PM +0800, Liu Ping Fan wrote: On q35, IRQ2/8 can be reserved for hpet timer 0/1. And pin 16~23 of ioapic can be dynamically assigned to hpet as guest chooses. So we introduce intcap property to do that. (currently, its value is IRQ2. Later, it should be set by board.) Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com --- hw/timer/hpet.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 8429eb3..5b11be4 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -25,6 +25,7 @@ */ #include hw/hw.h +#include hw/boards.h #include hw/i386/pc.h #include ui/console.h #include qemu/timer.h @@ -42,6 +43,9 @@ #define HPET_MSI_SUPPORT0 +/* Will fix: intcap is set by board, and should be 0 if nobody sets. */ +#define HPET_TN_INT_CAP_DEFAULT 0x4ULL + #define TYPE_HPET hpet #define HPET(obj) OBJECT_CHECK(HPETState, (obj), TYPE_HPET) @@ -73,6 +77,7 @@ typedef struct HPETState { uint8_t rtc_irq_level; qemu_irq pit_enabled; uint8_t num_timers; +uint32_t intcap; HPETTimer timer[HPET_MAX_TIMERS]; /* Memory-mapped, software visible registers */ @@ -663,8 +668,8 @@ static void hpet_reset(DeviceState *d) if (s-flags (1 HPET_MSI_SUPPORT)) { timer-config |= HPET_TN_FSB_CAP; } -/* advertise availability of ioapic inti2 */ -timer-config |= 0x0004ULL 32; +/* advertise availability of ioapic int */ +timer-config |= (uint64_t)s-intcap 32; timer-period = 0ULL; timer-wrap_flag = 0; } @@ -753,6 +758,7 @@ static void hpet_realize(DeviceState *dev, Error **errp) static Property hpet_device_properties[] = { DEFINE_PROP_UINT8(timers, HPETState, num_timers, HPET_MIN_TIMERS), DEFINE_PROP_BIT(msi, HPETState, flags, HPET_MSI_SUPPORT, false), +DEFINE_PROP_UINT32(intcap, HPETState, intcap, HPET_TN_INT_CAP_DEFAULT), DEFINE_PROP_END_OF_LIST(), }; Please add a macro for this name as you use it in other files later. Are you sure? This is not done for any other compat property. Paolo It's done if we use the property from C. See PCI_HOST_PROP_PCI_HOLE64_SIZE. You want compiler to catch errors, that's much better than a runtime failure. -- MST
[Qemu-devel] [PATCH] Use qemu-project.org domain name
qemu.org is held by a third-party and no core community contributor has access to the DNS configuration. This leaves the website exposed to outages due to DNS issues or IP address changes. For example, if the web server IP address needs to change we cannot guarantee qemu.org will point to it! The newer qemu-project.org domain name is owned by Anthony Liguori anth...@codemonkey.ws. You can confirm this by querying the whois information. Also note that the #qemu IRC channel topic already references qemu-project.org. Short of having a dedicated legal entity to hold the domain name on behalf of the community, qemu-project.org seems like the safest bet. Let's replace references to qemu.org with qemu-project.org. Signed-off-by: Stefan Hajnoczi stefa...@redhat.com --- This sprang from another email thread where qemu.org URLs were posted. I realized that there are still many references in the source tree. .gitmodules| 14 +++--- Changelog | 2 +- MAINTAINERS| 8 README | 2 +- docs/qmp/README| 2 +- docs/rdma.txt | 2 +- pc-bios/README | 2 +- qemu.nsi | 2 +- scripts/get_maintainer.pl | 2 +- scripts/qmp/qemu-ga-client | 2 +- version.rc | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.gitmodules b/.gitmodules index d7e3f3c..45e51e7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,27 +1,27 @@ [submodule roms/vgabios] path = roms/vgabios - url = git://git.qemu.org/vgabios.git/ + url = git://git.qemu-project.org/vgabios.git/ [submodule roms/seabios] path = roms/seabios - url = git://git.qemu.org/seabios.git/ + url = git://git.qemu-project.org/seabios.git/ [submodule roms/SLOF] path = roms/SLOF - url = git://git.qemu.org/SLOF.git + url = git://git.qemu-project.org/SLOF.git [submodule roms/ipxe] path = roms/ipxe - url = git://git.qemu.org/ipxe.git + url = git://git.qemu-project.org/ipxe.git [submodule roms/openbios] path = roms/openbios - url = git://git.qemu.org/openbios.git + url = git://git.qemu-project.org/openbios.git [submodule roms/qemu-palcode] path = roms/qemu-palcode url = git://github.com/rth7680/qemu-palcode.git [submodule roms/sgabios] path = roms/sgabios - url = git://git.qemu.org/sgabios.git + url = git://git.qemu-project.org/sgabios.git [submodule pixman] path = pixman url = git://anongit.freedesktop.org/pixman [submodule dtc] path = dtc - url = git://git.qemu.org/dtc.git + url = git://git.qemu-project.org/dtc.git diff --git a/Changelog b/Changelog index 13eebef..1249b8a 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,6 @@ This file documents changes for QEMU releases 0.12 and earlier. For changelog information for later releases, see -http://wiki.qemu.org/ChangeLog or look at the git history for +http://wiki.qemu-project.org/ChangeLog or look at the git history for more detailed information. diff --git a/MAINTAINERS b/MAINTAINERS index 5c3c70c..7466f96 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -855,21 +855,21 @@ Stable branches --- Stable 1.0 L: qemu-sta...@nongnu.org -T: git git://git.qemu.org/qemu-stable-1.0.git +T: git git://git.qemu-project.org/qemu-stable-1.0.git S: Orphan Stable 0.15 L: qemu-sta...@nongnu.org M: Andreas Färber afaer...@suse.de -T: git git://git.qemu.org/qemu-stable-0.15.git +T: git git://git.qemu-project.org/qemu-stable-0.15.git S: Supported Stable 0.14 L: qemu-sta...@nongnu.org -T: git git://git.qemu.org/qemu-stable-0.14.git +T: git git://git.qemu-project.org/qemu-stable-0.14.git S: Orphan Stable 0.10 L: qemu-sta...@nongnu.org -T: git git://git.qemu.org/qemu-stable-0.10.git +T: git git://git.qemu-project.org/qemu-stable-0.10.git S: Orphan diff --git a/README b/README index c77d126..c7c990d 100644 --- a/README +++ b/README @@ -1,3 +1,3 @@ -Read the documentation in qemu-doc.html or on http://wiki.qemu.org +Read the documentation in qemu-doc.html or on http://wiki.qemu-project.org - QEMU team diff --git a/docs/qmp/README b/docs/qmp/README index 85c4bc1..f6a3a03 100644 --- a/docs/qmp/README +++ b/docs/qmp/README @@ -84,4 +84,4 @@ Please, refer to the qapi-schema.json file for a complete command reference. QMP wiki page - -http://wiki.qemu.org/QMP +http://wiki.qemu-project.org/QMP diff --git a/docs/rdma.txt b/docs/rdma.txt index 8d1e003..2aca63b 100644 --- a/docs/rdma.txt +++ b/docs/rdma.txt @@ -1,7 +1,7 @@ (RDMA: Remote Direct Memory Access) RDMA Live Migration Specification, Version # 1 == -Wiki: http://wiki.qemu.org/Features/RDMALiveMigration +Wiki: http://wiki.qemu-project.org/Features/RDMALiveMigration Github: g...@github.com:hinesmr/qemu.git, 'rdma' branch Copyright (C) 2013
Re: [Qemu-devel] [PATCH v6 2/5] hpet: enable to entitle more irq pins for hpet
Il 10/10/2013 11:41, Michael S. Tsirkin ha scritto: Are you sure? This is not done for any other compat property. Paolo It's done if we use the property from C. See PCI_HOST_PROP_PCI_HOLE64_SIZE. You want compiler to catch errors, that's much better than a runtime failure. I agree, but I think there should be no need to use the property from C. Paolo
[Qemu-devel] [PATCH] block: Improve driver whitelist checks
The main intent of this patch is to consolidate the whitelist checks to a single point in the code instead of spreading it everywhere. This adds a nicer error message for read-only whitelisting, too, in places where it was still missing. The patch also contains a bonus bug fix: By finding the format first in bdrv_open() and then independently checking against the whitelist only later, we avoid the case that use of a non-whitelisted format results in probing rather than an error message. Previously, this could happen when using the driver=... option. Signed-off-by: Kevin Wolf kw...@redhat.com --- block.c| 10 +++--- blockdev.c | 8 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/block.c b/block.c index beea027..84c0eac 100644 --- a/block.c +++ b/block.c @@ -769,7 +769,11 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file, bs-read_only = !(open_flags BDRV_O_RDWR); if (use_bdrv_whitelist !bdrv_is_whitelisted(drv, bs-read_only)) { -error_setg(errp, Driver '%s' is not whitelisted, drv-format_name); +error_setg(errp, + !bs-read_only bdrv_is_whitelisted(drv, true) +? Driver '%s' can only be used for read-only devices +: Driver '%s' is not whitelisted, + drv-format_name); return -ENOTSUP; } @@ -881,7 +885,7 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename, /* Find the right block driver */ drvname = qdict_get_try_str(options, driver); if (drvname) { -drv = bdrv_find_whitelisted_format(drvname, !(flags BDRV_O_RDWR)); +drv = bdrv_find_format(drvname); if (!drv) { error_setg(errp, Unknown driver '%s', drvname); } @@ -1123,7 +1127,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, /* Find the right image format driver */ drvname = qdict_get_try_str(options, driver); if (drvname) { -drv = bdrv_find_whitelisted_format(drvname, !(flags BDRV_O_RDWR)); +drv = bdrv_find_format(drvname); qdict_del(options, driver); } diff --git a/blockdev.c b/blockdev.c index 92029d8..5f3cece 100644 --- a/blockdev.c +++ b/blockdev.c @@ -468,13 +468,9 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts, return NULL; } -drv = bdrv_find_whitelisted_format(buf, ro); +drv = bdrv_find_format(buf); if (!drv) { -if (!ro bdrv_find_whitelisted_format(buf, !ro)) { -error_report('%s' can be only used as read-only device., buf); -} else { -error_report('%s' invalid format, buf); -} +error_report('%s' invalid format, buf); return NULL; } } -- 1.8.1.4
Re: [Qemu-devel] [PATCH] vmdk: implment bdrv_get_info and bdrv_get_specific_info
Am 10.10.2013 um 09:07 hat Fam Zheng geschrieben: .bdrv_get_info reports cluster_size if it's a monolithic image. .bdrv_get_specific_info reports the image version (if applicable) and extent file name list. Signed-off-by: Fam Zheng f...@redhat.com Would it be useful to include the subformat as well? diff --git a/block/vmdk.c b/block/vmdk.c index 5d56e31..ff9bdac 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1814,6 +1814,48 @@ static int vmdk_has_zero_init(BlockDriverState *bs) return 1; } +static int vmdk_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) +{ +BDRVVmdkState *s = bs-opaque; +/* Normally the cluster sizes for all the extents in a vmdk image are the + * same, but we don't bother to check for this here and only report the + * value for the monolithic case. */ +if (s-num_extents == 1 !s-extents[0].flat) { +bdi-cluster_size = s-extents[0].cluster_sectors * 512; +} +return 0; +} + +static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs) +{ +int i; +BDRVVmdkState *s = bs-opaque; +ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1); +strList **next; + +*spec_info = (ImageInfoSpecific){ +.kind = IMAGE_INFO_SPECIFIC_KIND_VMDK, +.vmdk = g_new(ImageInfoSpecificVmdk, 1), +}; The first line has different spacing than the second one, so that the '=' signs aren't aligned to the same column. Probably not intentional? + +next = spec_info-vmdk-extents; +for (i = 0; i s-num_extents; i++) { +*next = g_new(strList, 1); +**next = (strList){ +.value = g_strdup(s-extents[i].file-filename), +.next = NULL, +}; +next = (*next)-next; +} + +if (s-num_extents == 1) { +spec_info-vmdk-version = s-extents[0].version; +spec_info-vmdk-has_version = true; +} + +return spec_info; +} + static QEMUOptionParameter vmdk_create_options[] = { { .name = BLOCK_OPT_SIZE, @@ -1866,6 +1908,8 @@ static BlockDriver bdrv_vmdk = { .bdrv_co_get_block_status = vmdk_co_get_block_status, .bdrv_get_allocated_file_size = vmdk_get_allocated_file_size, .bdrv_has_zero_init = vmdk_has_zero_init, +.bdrv_get_info= vmdk_get_info, +.bdrv_get_specific_info = vmdk_get_specific_info, .create_options = vmdk_create_options, }; diff --git a/qapi-schema.json b/qapi-schema.json index a1a81a4..b1e74b3 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -225,6 +225,17 @@ } } ## +# @ImageInfoSpecificVmdk: +# +# Since: 1.7 +## +{ 'type': 'ImageInfoSpecificVmdk', + 'data': { + '*version': 'int', + 'extents': ['str'] + } } Is the file name really the only relevant information about an extent? Above it looks like each extent has its version, and it also has its own subformat type, so perhaps making it a struct would make sense. +## # @ImageInfoSpecific: # # A discriminated record of image format specific information structures. @@ -234,7 +245,8 @@ { 'union': 'ImageInfoSpecific', 'data': { - 'qcow2': 'ImageInfoSpecificQCow2' + 'qcow2': 'ImageInfoSpecificQCow2', + 'vmdk': 'ImageInfoSpecificVmdk' } } Kevin
[Qemu-devel] [PATCH 0/2] qcow2: Undo leaked allocations in co_writev
If a write request on a qcow2 image spans more than one L2 table, qcow2_alloc_cluster_offset cannot allocate the required clusters in a single operation. This results in leaks, if a subsequent (atomic) allocation in that function fails, because qcow2_co_writev does not undo unused cluster allocations. This series implements that deallocation and provides a test for it. Max Reitz (2): qcow2: Undo leaked allocations in co_writev qemu-iotests: Extend test 026 block/qcow2.c | 7 +++ tests/qemu-iotests/026 | 31 +++ tests/qemu-iotests/026.out | 8 tests/qemu-iotests/026.out.nocache | 8 4 files changed, 54 insertions(+) -- 1.8.3.1
Re: [Qemu-devel] [PATCH] block: improve error message for read-only whitelisted driver
Am 10.10.2013 um 04:31 hat Fam Zheng geschrieben: Supplement of 7780d47, with message reworded and format probe case included: print an easy to understand message, when user tries to open a read-only format as read-write. Signed-off-by: Fam Zheng f...@redhat.com There's more to be cleaned up and fixed there. I'll look into it and send patches (it seems format=... is completely ignored at the moment, and the whitelist checks are duplicated in like three places). Kevin
Re: [Qemu-devel] [RFC] map 64-bit PCI devices after all possible RAM
Hi, So far from QEMU side it's partially (only memory region mapping and not ACPI window) configurable via {i440FX-pcihost|q35-pcihost}.pci-hole64-size property /me looks. Hmm, so the pci-hole64 memory region basically covers all non-memory area, leaving no free space. The window location can either be made configurable too, or we simply place it at the top of the address space, with address space being what the cpu can address according to cpuinfo. An earlier attempt by Michael to push complete PCI window placement info via etc/pci-info romfile to Seabios was rejected in favor of letting Seabios to program windows at hardcoded(32-bit/behind high mem) locations with a 64-bit window size (in ACPI) that covers all present devices but doesn't account for future PCI hotplug either. Correct. The ACPI tables should reflect what SeaBIOS has programmed, to avoid nasty dependencies between seabios and qemu. The same should apply to pci-hole64 IMO. That behavior maintained in his ACPI in QEMU series, see: http://patchwork.ozlabs.org/patch/281032/ acpi_get_pci_info()-i440fx_pcihost_get_pci_hole64_end()-pci_bus_get_w64_range() which is then embedded in ACPI table. So end result stays the same as before (no usable 64-bit PCI window for hotlug). Yes. And if we change seabios to do something else qemu nicely adapts to that, without requiring us to update things in lockstep. But 64-bit PCI window size, which is capped by QEMU to insane legacy 62 bits (memory region size), is a bit of orthogonal to freeing space for memory hotplug before it. Yep. So seabios should leave some free address space for memory hotplug. And if we change seabios to map the 64bit pci bars somewhere else we should also allow for a larger 64bit pci window to get some address space for pci hotplug. If we can do that without hints from the qemu I'd prefer that. 40 address lines allow 1TB, so we would place the window just below 1TB. Comments? More to the point if OS supports/enforces 1Tb physical address space,the RAM and 64-bit PCI hole are going to contend for it, QEMU could abort on startup if they both do not fit in CPU supported address space but I don't see what else it could do. Yes. Proposed patch favors RAM vs 64-bit PCI hole and moves the hole behind the possible RAM, which in present state of QEMU potentially leaves the rest of address space up to 62 bits for hole. So you'd end up with the 64bit hole being above the address space the virtual cpu claims to support. Not exactly nice either. Maybe things work nevertheless, maybe not ... Both cases can easily be fixed by just using a cpu with enough physical address lines to fit everything in, so I don't think we should bother too much about this corner case. Just in case this wasn't clear: my idea is that seabios figures the address space size at runtime, so the 1TB would NOT be hard-coded, it just served as example with the current default qemu cpu. So with my idea the address space would have all RAM at the bottom (well, starting at 4g). All PCI devices at the top. Free space for hotplug inbetween. RAM can grow up. PCI space can grow down. Note that qemu can make 64bit pci window in the acpi tables larger than what is actually used by the mapped bars, to make room for hotplugging, without any help from seabios (once the acpi table generation patches are merged). So with the current seabios (bars mapped above memory) it can set the end address higher. When seabios starts mapping the pci bars high it can set the start address lower. Anyone has a use case not handled by this approach? It has drawback that one can't get a working VM if QEMU is started in memory hotlug mode with old BIOS + PCI devices that require 64-bit bars, otherwise it's backward compatible. Yes. Updating seabios will be needed to use memory hotplug together with 64bit pci no matter how we tackle the issue.
Re: [Qemu-devel] [PATCH 1/2] vmdk: convert error reporting
On Thu, 10/10 12:39, Kevin Wolf wrote: Am 10.10.2013 um 09:20 hat Fam Zheng geschrieben: Convert fprintf(stderr,... to error API by passing around errp to functions those want to report error message. There are 2 more fprintf(stderr,... remaining in read/write code path. Signed-off-by: Fam Zheng f...@redhat.com --- block/vmdk.c | 42 +- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 5d56e31..a98ad23 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -483,7 +483,7 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent) static int vmdk_open_vmfs_sparse(BlockDriverState *bs, BlockDriverState *file, - int flags) + int flags, Error **errp) { int ret; uint32_t magic; The errp parameter is unused in this function. You should probably use error_setg_errno() for the failure cases. Callers generally don't distinguish different error return codes, so converted functions could return void instead of int. @@ -514,11 +514,11 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs, } static int vmdk_open_desc_file(BlockDriverState *bs, int flags, - uint64_t desc_offset); + uint64_t desc_offset, Error **errp); static int vmdk_open_vmdk4(BlockDriverState *bs, BlockDriverState *file, - int flags) + int flags, Error **errp) { int ret; uint32_t magic; @@ -534,7 +534,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, if (header.capacity == 0) { uint64_t desc_offset = le64_to_cpu(header.desc_offset); if (desc_offset) { -return vmdk_open_desc_file(bs, flags, desc_offset 9); +return vmdk_open_desc_file(bs, flags, desc_offset 9, errp); } } @@ -663,7 +663,7 @@ static int vmdk_parse_description(const char *desc, const char *opt_name, /* Open an extent file and append to bs array */ static int vmdk_open_sparse(BlockDriverState *bs, BlockDriverState *file, -int flags) +int flags, Error **errp) { uint32_t magic; @@ -674,10 +674,10 @@ static int vmdk_open_sparse(BlockDriverState *bs, magic = be32_to_cpu(magic); switch (magic) { case VMDK3_MAGIC: -return vmdk_open_vmfs_sparse(bs, file, flags); +return vmdk_open_vmfs_sparse(bs, file, flags, errp); break; case VMDK4_MAGIC: -return vmdk_open_vmdk4(bs, file, flags); +return vmdk_open_vmdk4(bs, file, flags, errp); break; default: return -EMEDIUMTYPE; @@ -686,7 +686,7 @@ static int vmdk_open_sparse(BlockDriverState *bs, } static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, -const char *desc_file_path) + const char *desc_file_path, Error **errp) { int ret; char access[11]; @@ -748,13 +748,13 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, extent-flat_start_offset = flat_offset 9; } else if (!strcmp(type, SPARSE) || !strcmp(type, VMFSSPARSE)) { /* SPARSE extent and VMFSSPARSE extent are both COWD sparse file*/ -ret = vmdk_open_sparse(bs, extent_file, bs-open_flags); +ret = vmdk_open_sparse(bs, extent_file, bs-open_flags, errp); if (ret) { bdrv_unref(extent_file); return ret; } } else { -fprintf(stderr, +error_setg(errp, VMDK: Not supported extent type \%s\.\n, type); return -ENOTSUP; } @@ -769,7 +769,7 @@ next_line: } static int vmdk_open_desc_file(BlockDriverState *bs, int flags, - uint64_t desc_offset) + uint64_t desc_offset, Error **errp) { int ret; char *buf = NULL; @@ -798,13 +798,13 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, strcmp(ct, vmfsSparse) strcmp(ct, twoGbMaxExtentSparse) strcmp(ct, twoGbMaxExtentFlat)) { -fprintf(stderr, +error_setg(errp, VMDK: Not supported image type \%s\.\n, ct); ret = -ENOTSUP; goto exit; } s-desc_offset = 0; -ret = vmdk_parse_extents(buf, bs, bs-file-filename); +ret = vmdk_parse_extents(buf, bs, bs-file-filename, errp); exit: g_free(buf); return ret; @@
[Qemu-devel] kvm binary is deprecated
Stefan , great thanks! We are setting up the scene for experiments... Unfortunately, we ran into yet one trouble. The configuration: Ubuntu 13.04, internal KVM, Qemu 1.4.0. VMs are created using virt-manager. When we try to create a VM the following error message appears: --- kvm binary is deprecated, please use qemu-system-x86_64 instead The same message appears when I try to run kvm --version. Question: how must be upgrade/degrade KVM oro Qemu in order to make them collaborate properly ? Thanks, Mark, Martin, Alex On Thu 10 Oct 11:02 2013 Stefan Hajnoczi wrote: On Mon, Oct 07, 2013 at 05:47:46PM +0300, Alexander Binun wrote: Our first task is to trace the traffic between individual VMs and between VMs and the VMM (the KVM driver). So we are searching for proper places to insert sniffer code. We suspect that some functions in qemu/hw/virtio should be targeted. And we will appreciate any hints on this places. My blog post about -netdev pcap in QEMU is useful for QEMU network code development setups. But the simplest way to sniff traffic in a production x86 KVM configuration is using tcpdump on the host. The common networking setup on the host is a Linux software bridge (e.g. virbr0) and one tap device per guest (e.g. vm001-tap, vm002-tap). The tap devices are added to the bridge so guests can communicate with each other. When a guest sends a packet, the vhost_net host kernel driver injects the packet into the guest's tap device. The Linux network stack then hands the packet from the tap device to the bridge. The bridge will forward the packet as appropriate. In guest-guest communication this means the packet is forwarded to the destination guest's tap device. The vhost_net driver instance for the destination guest then reads the packet from its tap device and places it into the guest's virtio-net receive buffer. This configuration means you have 3 places where you can run tcpdump on the host: 1. On the source guest's tap device (e.g. vm001-tap). 2. On the bridge interface (e.g. virbr0). 3. On the destination guest's tap device (e.g. vm002-tap). There are other options too like using openvswitch or macvtap. Openvswitch might be interesting because I think it allows you to add filtering rules into the kernel and send packets that match the rules up to a userspace process for inspection. Stefan
[Qemu-devel] [PATCH v12 0/8] Shared Library Module Support
This series implements feature of shared object building as described in: http://wiki.qemu.org/Features/Modules The main idea behind modules is to isolate dependencies on third party libraries from qemu executables, such as libglusterfs or librbd, so that the end users can install core qemu package with fewer dependencies. And only for those who want to use particular modules, need they install qemu-foo sub-package, which in turn requires libbar and libbiz packages. It's implemented in three steps: 1. The first patches fix current build system to correctly handle nested variables and object specific options: [01/08] ui/Makefile.objs: delete unnecessary cocoa.o dependency [02/08] make.rule: fix $(obj) to a real relative path [03/08] rule.mak: allow per object cflags and libs 2. The Makefile changes adds necessary options and rules to build DSO objects: [04/08] build-sys: introduce common-obj-m and block-obj-m for DSO 3. The next patch adds code to load modules from installed directory: [05/08] module: implement module loading A few more changes are following to complete it: [06/08] Makefile: install modules with make install [07/08] .gitignore: ignore module related files (dll, so, mo) In the end of series, the block drivers are converted: [08/08] block: convert block drivers linked with libs to modules v12: Rebase to current master, no conflict. Drop -Wl,--enable-new-tags -Wl,-rpath,'$$ORIGIN'. (Paolo) v11: [04] Link DSO with -Wl,--enable-new-dtags -Wl,-rpath,'$$ORIGIN' (Richard) [05] Reuse module_init_type in module_load, no separate load type enums. Separate list of modules by type. It's simply list of built modules now. No whitelist option in configure. Support multiple module_init() in single module. v10: All modules in a single directory (moddir), with module type prefixed: /usr/lib/qemu/block-{curl,iscsi,...}.so The module names for user to list in module whitelist is consequently: block-curl, block-iscsi, ui-*, etc. In Makfile, the installed module filename is simply generated by: $(subst /,-,%.so) Which is also the rule for module names. [05] Add #undef CONFIG_MODULE_WHITELIST in config-host.h. Use static array for whitelist. (Richard) Fam Zheng (7): make.rule: fix $(obj) to a real relative path rule.mak: allow per object cflags and libs build-sys: introduce common-obj-m and block-obj-m for DSO module: implement module loading Makefile: install modules with make install .gitignore: ignore module related files (dll, so, mo) block: convert block drivers linked with libs to modules Peter Maydell (1): ui/Makefile.objs: delete unnecessary cocoa.o dependency .gitignore| 3 ++ Makefile | 30 +- Makefile.objs | 19 ++--- Makefile.target | 21 -- block/Makefile.objs | 11 +- configure | 76 +++ include/qemu/module.h | 12 ++ module-common.c | 10 + rules.mak | 80 +++-- scripts/create_config | 14 +++ ui/Makefile.objs | 2 - util/module.c | 107 +- 12 files changed, 320 insertions(+), 65 deletions(-) create mode 100644 module-common.c -- 1.8.3.1
[Qemu-devel] [PATCH v12 1/8] ui/Makefile.objs: delete unnecessary cocoa.o dependency
From: Peter Maydell peter.mayd...@linaro.org Delete an unnecessary dependency for cocoa.o; we already have a general rule that tells Make that we can build a .o file from a .m source using an ObjC compiler, so this specific rule is unnecessary. Further, it is using the dubious construct $(SRC_PATH)/$(obj) to get at the source directory, which will break when $(obj) is redefined as part of the preparation for per-object library support. Signed-off-by: Peter Maydell peter.mayd...@linaro.org Signed-off-by: Fam Zheng f...@redhat.com --- ui/Makefile.objs | 2 -- 1 file changed, 2 deletions(-) diff --git a/ui/Makefile.objs b/ui/Makefile.objs index 6ddc0de..f33be47 100644 --- a/ui/Makefile.objs +++ b/ui/Makefile.objs @@ -17,6 +17,4 @@ common-obj-$(CONFIG_GTK) += gtk.o x_keymap.o $(obj)/sdl.o $(obj)/sdl_zoom.o: QEMU_CFLAGS += $(SDL_CFLAGS) -$(obj)/cocoa.o: $(SRC_PATH)/$(obj)/cocoa.m - $(obj)/gtk.o: QEMU_CFLAGS += $(GTK_CFLAGS) $(VTE_CFLAGS) -- 1.8.3.1
[Qemu-devel] [PATCH v12 2/8] make.rule: fix $(obj) to a real relative path
Makefile.target includes rule.mak and unnested common-obj-y, then prefix them with '../', this will ignore object specific QEMU_CFLAGS in subdir Makefile.objs: $(obj)/curl.o: QEMU_CFLAGS += $(CURL_CFLAGS) Because $(obj) here is './block', instead of '../block'. This doesn't hurt compiling because we basically build all .o from top Makefile, before entering Makefile.target, but it will affact arriving per-object libs support. The starting point of $(obj) is passed in as argument of unnest-vars, as well as nested variables, so that different Makefiles can pass in a right value. Signed-off-by: Fam Zheng f...@redhat.com --- Makefile| 14 ++ Makefile.objs | 17 + Makefile.target | 17 + configure | 1 + rules.mak | 14 +- 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 60fb87e..44eb55e 100644 --- a/Makefile +++ b/Makefile @@ -115,6 +115,16 @@ defconfig: ifneq ($(wildcard config-host.mak),) include $(SRC_PATH)/Makefile.objs +endif + +dummy := $(call unnest-vars,, \ +stub-obj-y \ +util-obj-y \ +qga-obj-y \ +block-obj-y \ +common-obj-y) + +ifneq ($(wildcard config-host.mak),) include $(SRC_PATH)/tests/Makefile endif ifeq ($(CONFIG_SMARTCARD_NSS),y) @@ -123,6 +133,10 @@ endif all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all +vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) + +vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS) + config-host.h: config-host.h-timestamp config-host.h-timestamp: config-host.mak qemu-options.def: $(SRC_PATH)/qemu-options.hx diff --git a/Makefile.objs b/Makefile.objs index 2b6c1fe..91235a6 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -41,7 +41,7 @@ libcacard-y += libcacard/vcardt.o # single QEMU executable should support all CPUs and machines. ifeq ($(CONFIG_SOFTMMU),y) -common-obj-y = $(block-obj-y) blockdev.o blockdev-nbd.o block/ +common-obj-y = blockdev.o blockdev-nbd.o block/ common-obj-y += net/ common-obj-y += readline.o common-obj-y += qdev-monitor.o device-hotplug.o @@ -110,18 +110,3 @@ version-lobj-$(CONFIG_WIN32) += $(BUILD_DIR)/version.lo # by libqemuutil.a. These should be moved to a separate .json schema. qga-obj-y = qga/ qapi-types.o qapi-visit.o qga-vss-dll-obj-y = qga/ - -vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) - -vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS) - -QEMU_CFLAGS+=$(GLIB_CFLAGS) - -nested-vars += \ - stub-obj-y \ - util-obj-y \ - qga-obj-y \ - qga-vss-dll-obj-y \ - block-obj-y \ - common-obj-y -dummy := $(call unnest-vars) diff --git a/Makefile.target b/Makefile.target index 9a49852..87906ea 100644 --- a/Makefile.target +++ b/Makefile.target @@ -143,13 +143,22 @@ endif # CONFIG_SOFTMMU # Workaround for http://gcc.gnu.org/PR55489, see configure. %/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS) -nested-vars += obj-y +dummy := $(call unnest-vars,,obj-y) -# This resolves all nested paths, so it must come last +# we are making another call to unnest-vars with different vars, protect obj-y, +# it can be overriden in subdir Makefile.objs +obj-y-save := $(obj-y) + +block-obj-y := +common-obj-y := include $(SRC_PATH)/Makefile.objs +dummy := $(call unnest-vars,..,block-obj-y common-obj-y) + +# Now restore obj-y +obj-y := $(obj-y-save) + +all-obj-y = $(obj-y) $(common-obj-y) $(block-obj-y) -all-obj-y = $(obj-y) -all-obj-y += $(addprefix ../, $(common-obj-y)) ifndef CONFIG_HAIKU LIBS+=-lm diff --git a/configure b/configure index 23dbaaf..f66adb7 100755 --- a/configure +++ b/configure @@ -2286,6 +2286,7 @@ fi if $pkg_config --atleast-version=$glib_req_ver gthread-2.0; then glib_cflags=`$pkg_config --cflags gthread-2.0` glib_libs=`$pkg_config --libs gthread-2.0` +CFLAGS=$glib_cflags $CFLAGS LIBS=$glib_libs $LIBS libs_qga=$glib_libs $libs_qga else diff --git a/rules.mak b/rules.mak index abc2e84..01e552e 100644 --- a/rules.mak +++ b/rules.mak @@ -110,9 +110,6 @@ clean: clean-timestamp # magic to descend into other directories -obj := . -old-nested-dirs := - define push-var $(eval save-$2-$1 = $(value $1)) $(eval $1 :=) @@ -126,9 +123,11 @@ endef define unnest-dir $(foreach var,$(nested-vars),$(call push-var,$(var),$1/)) -$(eval obj := $(obj)/$1) +$(eval obj-parent-$1 := $(obj)) +$(eval obj := $(if $(obj),$(obj)/$1,$1)) $(eval include $(SRC_PATH)/$1/Makefile.objs) -$(eval obj := $(patsubst %/$1,%,$(obj))) +$(eval obj := $(obj-parent-$1)) +$(eval obj-parent-$1 := ) $(foreach var,$(nested-vars),$(call pop-var,$(var),$1/)) endef @@ -143,7 +142,12 @@ $(if $(nested-dirs), endef define unnest-vars +$(eval obj := $1) +$(eval nested-vars := $2) +$(eval old-nested-dirs := ) $(call unnest-vars-1) +$(if $1,$(foreach v,$(nested-vars),$(eval \ + $v := $(addprefix $1/,$($v) $(foreach var,$(nested-vars),$(eval $(var) := $(filter-out %/, $($(var) $(shell mkdir -p $(sort $(foreach
[Qemu-devel] [PATCH v12 3/8] rule.mak: allow per object cflags and libs
Adds extract-libs in LINK to expand any per object libs, the syntax to define such a libs options is like: foo.o-libs := $(CURL_LIBS) in block/Makefile.objs. Similarly, foo.o-cflags := $(FOO_CFLAGS) is also supported. foo.o must be listed a nested var (e.g. common-obj-y) to make the option variables effective. Signed-off-by: Fam Zheng f...@redhat.com --- rules.mak | 19 --- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/rules.mak b/rules.mak index 01e552e..e732261 100644 --- a/rules.mak +++ b/rules.mak @@ -21,15 +21,17 @@ QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d # Same as -I$(SRC_PATH) -I., but for the nested source/object directories QEMU_INCLUDES += -I$(D) -I$(@D) +extract-libs = $(strip $(foreach o,$1,$($o-libs))) + %.o: %.c - $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $, CC$(TARGET_DIR)$@) + $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) -c -o $@ $, CC$(TARGET_DIR)$@) %.o: %.rc $(call quiet-command,$(WINDRES) -I. -o $@ $, RC$(TARGET_DIR)$@) ifeq ($(LIBTOOL),) LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \ $(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \ - $(LIBS), LINK $(TARGET_DIR)$@) + $(call extract-libs,$^) $(LIBS), LINK $(TARGET_DIR)$@) else LIBTOOL += $(if $(V),,--quiet) %.lo: %.c @@ -45,7 +47,7 @@ LINK = $(call quiet-command,\ $(sort $(filter %.o, $1)) $(filter-out %.o, $1) \ $(if $(filter %.lo %.la,$^),$(version-lobj-y),$(version-obj-y)) \ $(if $(filter %.lo %.la,$^),$(LIBTOOLFLAGS)) \ - $(LIBS),$(if $(filter %.lo %.la,$^),lt LINK , LINK )$(TARGET_DIR)$@) + $(call extract-libs,$^) $(LIBS),$(if $(filter %.lo %.la,$^),lt LINK , LINK )$(TARGET_DIR)$@) endif %.asm: %.S @@ -121,11 +123,22 @@ $(eval $1 = $(value save-$2-$1) $$(subdir-$2-$1)) $(eval save-$2-$1 :=) endef +define fix-obj-vars +$(foreach v,$($1), \ + $(if $($v-cflags), \ + $(eval $2$v-cflags := $($v-cflags)) \ + $(eval $v-cflags := )) \ + $(if $($v-libs), \ + $(eval $2$v-libs := $($v-libs)) \ + $(eval $v-libs := ))) +endef + define unnest-dir $(foreach var,$(nested-vars),$(call push-var,$(var),$1/)) $(eval obj-parent-$1 := $(obj)) $(eval obj := $(if $(obj),$(obj)/$1,$1)) $(eval include $(SRC_PATH)/$1/Makefile.objs) +$(foreach v,$(nested-vars),$(call fix-obj-vars,$v,$(if $(obj),$(obj)/))) $(eval obj := $(obj-parent-$1)) $(eval obj-parent-$1 := ) $(foreach var,$(nested-vars),$(call pop-var,$(var),$1/)) -- 1.8.3.1
[Qemu-devel] [PATCH v12 6/8] Makefile: install modules with make install
Install all the modules to ${MODDIR}. Signed-off-by: Fam Zheng f...@redhat.com --- Makefile | 6 ++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 51de298..356ff5c 100644 --- a/Makefile +++ b/Makefile @@ -365,6 +365,12 @@ install-datadir install-localstatedir ifneq ($(TOOLS),) $(INSTALL_PROG) $(STRIP_OPT) $(TOOLS) $(DESTDIR)$(bindir) endif +ifneq ($(CONFIG_MODULES),) + $(INSTALL_DIR) $(DESTDIR)$(moddir) + for s in $(patsubst %.mo,%$(DSOSUF),$(modules-m)); do \ + $(INSTALL_PROG) $(STRIP_OPT) $$s $(DESTDIR)$(moddir)/$${s//\//-}; \ + done +endif ifneq ($(HELPERS-y),) $(INSTALL_DIR) $(DESTDIR)$(libexecdir) $(INSTALL_PROG) $(STRIP_OPT) $(HELPERS-y) $(DESTDIR)$(libexecdir) -- 1.8.3.1
[Qemu-devel] [PATCH v12 4/8] build-sys: introduce common-obj-m and block-obj-m for DSO
Add necessary rules and flags for shared object generation. $(common-obj-m) will include $(block-obj-m), like $(common-obj-y) does for $(block-obj-y). The new rules introduced here are: 0) For all %.so compiling: QEMU_CFLAGS += -fPIC 1) %.o in $(common-obj-m) is compiled to %.o, then linked to %.so. 2) %.mo in $(common-obj-m) is the placeholder for %.so for pattern matching in Makefile. It's linked to -shared with all its dependencies (multiple *.o) as input. Which means the list of depended objects must be specified in each sub-Makefile.objs: foo.mo-objs := bar.o baz.o qux.o in the same style with foo.o-cflags and foo.o-libs. The objects here will be prefixed with $(obj)/ if it's a subdirectory Makefile.objs. Also introduce --enable-modules in configure, the option will enable support of shared object build. Otherwise objects are static linked to executables. Signed-off-by: Fam Zheng f...@redhat.com --- Makefile| 9 +++-- Makefile.objs | 2 ++ Makefile.target | 6 +- configure | 14 ++ rules.mak | 54 +- 5 files changed, 73 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 44eb55e..a8488d6 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,9 @@ dummy := $(call unnest-vars,, \ util-obj-y \ qga-obj-y \ block-obj-y \ -common-obj-y) +block-obj-m \ +common-obj-y \ +common-obj-m) ifneq ($(wildcard config-host.mak),) include $(SRC_PATH)/tests/Makefile @@ -131,7 +133,7 @@ ifeq ($(CONFIG_SMARTCARD_NSS),y) include $(SRC_PATH)/libcacard/Makefile endif -all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all +all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) @@ -249,6 +251,9 @@ clean: rm -f qemu-options.def find . -name '*.[oda]' -type f -exec rm -f {} + find . -name '*.l[oa]' -type f -exec rm -f {} + + find . -name '*.so' -type f -exec rm -f {} + + find . -name '*.mo' -type f -exec rm -f {} + + find . -name '*.dll' -type f -exec rm -f {} + rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~ rm -f fsdev/*.pod rm -rf .libs */.libs diff --git a/Makefile.objs b/Makefile.objs index 91235a6..072d2e5 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -19,6 +19,8 @@ block-obj-y += qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o block-obj-y += qemu-coroutine-sleep.o block-obj-y += coroutine-$(CONFIG_COROUTINE_BACKEND).o +block-obj-m = block/ + ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy) # Lots of the fsdev/9pcode is pulled in by vl.c via qemu_fsdev_add. # only pull in the actual virtio-9p device if we also enabled virtio. diff --git a/Makefile.target b/Makefile.target index 87906ea..7fb9e4d 100644 --- a/Makefile.target +++ b/Makefile.target @@ -152,7 +152,11 @@ obj-y-save := $(obj-y) block-obj-y := common-obj-y := include $(SRC_PATH)/Makefile.objs -dummy := $(call unnest-vars,..,block-obj-y common-obj-y) +dummy := $(call unnest-vars,.., \ + block-obj-y \ + block-obj-m \ + common-obj-y \ + common-obj-m) # Now restore obj-y obj-y := $(obj-y-save) diff --git a/configure b/configure index f66adb7..7b8771a 100755 --- a/configure +++ b/configure @@ -190,6 +190,9 @@ mingw32=no gcov=no gcov_tool=gcov EXESUF= +DSOSUF=.so +LDFLAGS_SHARED=-shared +modules=no prefix=/usr/local mandir=\${prefix}/share/man datadir=\${prefix}/share @@ -496,6 +499,7 @@ OpenBSD) Darwin) bsd=yes darwin=yes + LDFLAGS_SHARED=-bundle if [ $cpu = x86_64 ] ; then QEMU_CFLAGS=-arch x86_64 $QEMU_CFLAGS LDFLAGS=-arch x86_64 $LDFLAGS @@ -591,6 +595,7 @@ fi if test $mingw32 = yes ; then EXESUF=.exe + DSOSUF=.dll QEMU_CFLAGS=-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) QEMU_CFLAGS=-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS @@ -655,6 +660,8 @@ for opt do ;; --disable-debug-info) ;; + --enable-modules) modules=yes + ;; --cpu=*) ;; --target-list=*) target_list=$optarg @@ -1080,6 +1087,7 @@ echo --libdir=PATHinstall libraries in PATH echo --sysconfdir=PATHinstall config in PATH$confsuffix echo --localstatedir=PATH install local state in PATH (set at runtime on win32) echo --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix] +echo --enable-modules enable modules support echo --enable-debug-tcg enable TCG debugging echo --disable-debug-tcg disable TCG debugging (default) echo --enable-debug-info enable debugging information (default) @@ -3677,6 +3685,7 @@ echo python$python if test $slirp = yes ; then echo smbd $smbd fi
[Qemu-devel] [PATCH v12 7/8] .gitignore: ignore module related files (dll, so, mo)
Signed-off-by: Fam Zheng f...@redhat.com --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 8e1b73f..ac679ea 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,9 @@ fsdev/virtfs-proxy-helper.pod *.cp *.dvi *.exe +*.dll +*.so +*.mo *.fn *.ky *.log -- 1.8.3.1
[Qemu-devel] [PATCH v12 5/8] module: implement module loading
This patch adds loading, stamp checking and initialization of modules. The init function of dynamic module is no longer directly called as __attribute__((constructor)) in static linked version, it is called only after passed the checking of presense of stamp symbol: qemu_stamp_$(date +%s$$$RANDOM) With this, modules built from a different tree/version/configure will not be loaded. The module loading code requires gmodule-2.0. Signed-off-by: Fam Zheng f...@redhat.com --- Makefile | 3 ++ configure | 32 ++- include/qemu/module.h | 12 ++ module-common.c | 10 + rules.mak | 7 ++-- scripts/create_config | 14 +++ util/module.c | 107 +- 7 files changed, 170 insertions(+), 15 deletions(-) create mode 100644 module-common.c diff --git a/Makefile b/Makefile index a8488d6..51de298 100644 --- a/Makefile +++ b/Makefile @@ -196,6 +196,9 @@ Makefile: $(version-obj-y) $(version-lobj-y) libqemustub.a: $(stub-obj-y) libqemuutil.a: $(util-obj-y) qapi-types.o qapi-visit.o +block-modules = $(foreach o,$(block-obj-m),$(basename $(subst /,-,$o)),) NULL +util/module.o-cflags = -D'CONFIG_BLOCK_MODULES=$(block-modules)' + ## qemu-img.o: qemu-img-cmds.h diff --git a/configure b/configure index 7b8771a..dd901ab 100755 --- a/configure +++ b/configure @@ -199,6 +199,7 @@ datadir=\${prefix}/share qemu_docdir=\${prefix}/share/doc/qemu bindir=\${prefix}/bin libdir=\${prefix}/lib +moddir=\${prefix}/lib/qemu libexecdir=\${prefix}/libexec includedir=\${prefix}/include sysconfdir=\${prefix}/etc @@ -660,7 +661,8 @@ for opt do ;; --disable-debug-info) ;; - --enable-modules) modules=yes + --enable-modules) + modules=yes ;; --cpu=*) ;; @@ -685,6 +687,8 @@ for opt do ;; --libdir=*) libdir=$optarg ;; + --moddir=*) moddir=$optarg + ;; --libexecdir=*) libexecdir=$optarg ;; --includedir=*) includedir=$optarg @@ -1084,6 +1088,7 @@ echo --datadir=PATH install firmware in PATH$confsuffix echo --docdir=PATHinstall documentation in PATH$confsuffix echo --bindir=PATHinstall binaries in PATH echo --libdir=PATHinstall libraries in PATH +echo --moddir=PATHinstall modules in PATH echo --sysconfdir=PATHinstall config in PATH$confsuffix echo --localstatedir=PATH install local state in PATH (set at runtime on win32) echo --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix] @@ -2291,15 +2296,19 @@ if test $mingw32 = yes; then else glib_req_ver=2.12 fi -if $pkg_config --atleast-version=$glib_req_ver gthread-2.0; then -glib_cflags=`$pkg_config --cflags gthread-2.0` -glib_libs=`$pkg_config --libs gthread-2.0` -CFLAGS=$glib_cflags $CFLAGS -LIBS=$glib_libs $LIBS -libs_qga=$glib_libs $libs_qga -else -error_exit glib-$glib_req_ver required to compile QEMU -fi + +for i in gthread-2.0 gmodule-2.0; do +if $pkg_config --atleast-version=$glib_req_ver $i; then +glib_cflags=`$pkg_config --cflags $i` +glib_libs=`$pkg_config --libs $i` +CFLAGS=$glib_cflags $CFLAGS +LIBS=$glib_libs $LIBS +libs_qga=$glib_libs $libs_qga +else +error_exit glib-$glib_req_ver required to compile QEMU +fi +done + ## # pixman support probe @@ -3660,6 +3669,7 @@ echo Install prefix$prefix echo BIOS directory`eval echo $qemu_datadir` echo binary directory `eval echo $bindir` echo library directory `eval echo $libdir` +echo module directory `eval echo $moddir` echo libexec directory `eval echo $libexecdir` echo include directory `eval echo $includedir` echo config directory `eval echo $sysconfdir` @@ -3786,6 +3796,7 @@ echo all: $config_host_mak echo prefix=$prefix $config_host_mak echo bindir=$bindir $config_host_mak echo libdir=$libdir $config_host_mak +echo moddir=$moddir $config_host_mak echo libexecdir=$libexecdir $config_host_mak echo includedir=$includedir $config_host_mak echo mandir=$mandir $config_host_mak @@ -3804,6 +3815,7 @@ echo libs_softmmu=$libs_softmmu $config_host_mak echo ARCH=$ARCH $config_host_mak +echo CONFIG_STAMP=$(date +%s$$$RANDOM) $config_host_mak if test $modules = yes; then echo CONFIG_MODULES=y $config_host_mak fi diff --git a/include/qemu/module.h b/include/qemu/module.h index c4ccd57..47b7f1d 100644 --- a/include/qemu/module.h +++ b/include/qemu/module.h @@ -14,11 +14,22 @@ #ifndef QEMU_MODULE_H #define QEMU_MODULE_H +#ifdef BUILD_DSO +void DSO_STAMP_FUN(void); +/* For error message, this function is an identification of qemu module */ +void qemu_module_dummy(void); + +#define module_init(function, type) \ +static void __attribute__((constructor))
[Qemu-devel] [PATCH v12 8/8] block: convert block drivers linked with libs to modules
The converted block drivers are: curl iscsi rbd ssh glusterfs no longer adds flags and libs for them to global variables, instead create config-host.mak variables like FOO_CFLAGS and FOO_LIBS, which is used as per object cflags and libs. Signed-off-by: Fam Zheng f...@redhat.com --- block/Makefile.objs | 11 ++- configure | 33 +++-- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/block/Makefile.objs b/block/Makefile.objs index 3bb85b5..f98d379 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -23,4 +23,13 @@ common-obj-y += commit.o common-obj-y += mirror.o common-obj-y += backup.o -$(obj)/curl.o: QEMU_CFLAGS+=$(CURL_CFLAGS) +iscsi.o-cflags := $(LIBISCSI_CFLAGS) +iscsi.o-libs := $(LIBISCSI_LIBS) +curl.o-cflags := $(CURL_CFLAGS) +curl.o-libs:= $(CURL_LIBS) +rbd.o-cflags := $(RBD_CFLAGS) +rbd.o-libs := $(RBD_LIBS) +gluster.o-cflags := $(GLUSTERFS_CFLAGS) +gluster.o-libs := $(GLUSTERFS_LIBS) +ssh.o-cflags := $(LIBSSH2_CFLAGS) +ssh.o-libs := $(LIBSSH2_LIBS) diff --git a/configure b/configure index dd901ab..fab75ad 100755 --- a/configure +++ b/configure @@ -2257,8 +2257,6 @@ EOF curl_libs=`$curlconfig --libs 2/dev/null` if compile_prog $curl_cflags $curl_libs ; then curl=yes -libs_tools=$curl_libs $libs_tools -libs_softmmu=$curl_libs $libs_softmmu else if test $curl = yes ; then feature_not_found curl @@ -2418,8 +2416,6 @@ EOF rbd_libs=-lrbd -lrados if compile_prog $rbd_libs ; then rbd=yes -libs_tools=$rbd_libs $libs_tools -libs_softmmu=$rbd_libs $libs_softmmu else if test $rbd = yes ; then feature_not_found rados block device @@ -2436,9 +2432,6 @@ if test $libssh2 != no ; then libssh2_cflags=`$pkg_config libssh2 --cflags` libssh2_libs=`$pkg_config libssh2 --libs` libssh2=yes -libs_tools=$libssh2_libs $libs_tools -libs_softmmu=$libssh2_libs $libs_softmmu -QEMU_CFLAGS=$QEMU_CFLAGS $libssh2_cflags else if test $libssh2 = yes ; then error_exit libssh2 = $min_libssh2_version required for --enable-libssh2 @@ -2654,9 +2647,6 @@ if test $glusterfs != no ; then glusterfs=yes glusterfs_cflags=`$pkg_config --cflags glusterfs-api` glusterfs_libs=`$pkg_config --libs glusterfs-api` -CFLAGS=$CFLAGS $glusterfs_cflags -libs_tools=$glusterfs_libs $libs_tools -libs_softmmu=$glusterfs_libs $libs_softmmu if $pkg_config --atleast-version=5 glusterfs-api; then glusterfs_discard=yes fi @@ -3024,11 +3014,9 @@ EOF libiscsi=yes libiscsi_cflags=$($pkg_config --cflags libiscsi) libiscsi_libs=$($pkg_config --libs libiscsi) -CFLAGS=$CFLAGS $libiscsi_cflags -LIBS=$LIBS $libiscsi_libs elif compile_prog -liscsi ; then libiscsi=yes -LIBS=$LIBS -liscsi +libiscsi_libs=-liscsi else if test $libiscsi = yes ; then feature_not_found libiscsi @@ -4016,8 +4004,9 @@ if test $bswap_h = yes ; then echo CONFIG_MACHINE_BSWAP_H=y $config_host_mak fi if test $curl = yes ; then - echo CONFIG_CURL=y $config_host_mak + echo CONFIG_CURL=m $config_host_mak echo CURL_CFLAGS=$curl_cflags $config_host_mak + echo CURL_LIBS=$curl_libs $config_host_mak fi if test $brlapi = yes ; then echo CONFIG_BRLAPI=y $config_host_mak @@ -4106,7 +4095,9 @@ if test $glx = yes ; then fi if test $libiscsi = yes ; then - echo CONFIG_LIBISCSI=y $config_host_mak + echo CONFIG_LIBISCSI=m $config_host_mak + echo LIBISCSI_CFLAGS=$libiscsi_cflags $config_host_mak + echo LIBISCSI_LIBS=$libiscsi_libs $config_host_mak fi if test $seccomp = yes; then @@ -4127,7 +4118,9 @@ if test $qom_cast_debug = yes ; then echo CONFIG_QOM_CAST_DEBUG=y $config_host_mak fi if test $rbd = yes ; then - echo CONFIG_RBD=y $config_host_mak + echo CONFIG_RBD=m $config_host_mak + echo RBD_CFLAGS=$rbd_cflags $config_host_mak + echo RBD_LIBS=$rbd_libs $config_host_mak fi echo CONFIG_COROUTINE_BACKEND=$coroutine $config_host_mak @@ -4170,7 +4163,9 @@ if test $getauxval = yes ; then fi if test $glusterfs = yes ; then - echo CONFIG_GLUSTERFS=y $config_host_mak + echo CONFIG_GLUSTERFS=m $config_host_mak + echo GLUSTERFS_CFLAGS=$glusterfs_cflags $config_host_mak + echo GLUSTERFS_LIBS=$glusterfs_libs $config_host_mak fi if test $glusterfs_discard = yes ; then @@ -4178,7 +4173,9 @@ if test $glusterfs_discard = yes ; then fi if test $libssh2 = yes ; then - echo CONFIG_LIBSSH2=y $config_host_mak + echo CONFIG_LIBSSH2=m $config_host_mak + echo LIBSSH2_CFLAGS=$libssh2_cflags $config_host_mak + echo LIBSSH2_LIBS=$libssh2_libs $config_host_mak fi if test $virtio_blk_data_plane = yes ; then -- 1.8.3.1
Re: [Qemu-devel] [RFC] map 64-bit PCI devices after all possible RAM
On Thu, Oct 10, 2013 at 12:56:23PM +0200, Gerd Hoffmann wrote: Hi, So far from QEMU side it's partially (only memory region mapping and not ACPI window) configurable via {i440FX-pcihost|q35-pcihost}.pci-hole64-size property /me looks. Hmm, so the pci-hole64 memory region basically covers all non-memory area, leaving no free space. This is kind of derived from the PIIX spec although of course it did not discuss 64 bit memory. The window location can either be made configurable too, or we simply place it at the top of the address space, with address space being what the cpu can address according to cpuinfo. An earlier attempt by Michael to push complete PCI window placement info via etc/pci-info romfile to Seabios was rejected in favor of letting Seabios to program windows at hardcoded(32-bit/behind high mem) locations with a 64-bit window size (in ACPI) that covers all present devices but doesn't account for future PCI hotplug either. Correct. The ACPI tables should reflect what SeaBIOS has programmed, to avoid nasty dependencies between seabios and qemu. The same should apply to pci-hole64 IMO. That behavior maintained in his ACPI in QEMU series, see: http://patchwork.ozlabs.org/patch/281032/ acpi_get_pci_info()-i440fx_pcihost_get_pci_hole64_end()-pci_bus_get_w64_range() which is then embedded in ACPI table. So end result stays the same as before (no usable 64-bit PCI window for hotlug). Yes. And if we change seabios to do something else qemu nicely adapts to that, without requiring us to update things in lockstep. But 64-bit PCI window size, which is capped by QEMU to insane legacy 62 bits (memory region size), is a bit of orthogonal to freeing space for memory hotplug before it. Yep. So seabios should leave some free address space for memory hotplug. And if we change seabios to map the 64bit pci bars somewhere else we should also allow for a larger 64bit pci window to get some address space for pci hotplug. If we can do that without hints from the qemu I'd prefer that. I think the simplest way to do all this is simply to tell seabios that we have more memory. seabios already programs 64 bit BARs higher than memory. No new interface seems necessary. 40 address lines allow 1TB, so we would place the window just below 1TB. Comments? More to the point if OS supports/enforces 1Tb physical address space,the RAM and 64-bit PCI hole are going to contend for it, QEMU could abort on startup if they both do not fit in CPU supported address space but I don't see what else it could do. Yes. Proposed patch favors RAM vs 64-bit PCI hole and moves the hole behind the possible RAM, which in present state of QEMU potentially leaves the rest of address space up to 62 bits for hole. So you'd end up with the 64bit hole being above the address space the virtual cpu claims to support. Not exactly nice either. Maybe things work nevertheless, maybe not ... Both cases can easily be fixed by just using a cpu with enough physical address lines to fit everything in, so I don't think we should bother too much about this corner case. Just in case this wasn't clear: my idea is that seabios figures the address space size at runtime, so the 1TB would NOT be hard-coded, it just served as example with the current default qemu cpu. So with my idea the address space would have all RAM at the bottom (well, starting at 4g). All PCI devices at the top. Free space for hotplug inbetween. RAM can grow up. PCI space can grow down. Note that qemu can make 64bit pci window in the acpi tables larger than what is actually used by the mapped bars, to make room for hotplugging, without any help from seabios (once the acpi table generation patches are merged). So with the current seabios (bars mapped above memory) it can set the end address higher. When seabios starts mapping the pci bars high it can set the start address lower. Anyone has a use case not handled by this approach? I think the issue is with legacy guests. E.g. if VCPU claims to support 50 bit of memory do we put high PCI memory at 1 50? If yes old guests which expect at most 40 bit will not be able to use it. It has drawback that one can't get a working VM if QEMU is started in memory hotlug mode with old BIOS + PCI devices that require 64-bit bars, otherwise it's backward compatible. Yes. Updating seabios will be needed to use memory hotplug together with 64bit pci no matter how we tackle the issue.
Re: [Qemu-devel] [PATCHv3 1/3] seccomp: adding blacklist support
On 10/09/2013 05:36 PM, Paul Moore wrote: On Tuesday, October 08, 2013 09:42:24 PM Eduardo Otubo wrote: v3: The -netdev tap option is checked in the vl.c file during the process of the command line argument list. It sets tap_enabled to true or false according to the configuration found. Later at the seccomp filter installation, this value is checked wheter to install or not this feature. I like the idea of slowly making the QEMU syscall filter dependent on the runtime configuration. With that in mind, I wonder if we should have a more general purpose API in include/sysemu/seccomp.h that allows QEMU to indicate to the the QEMU/seccomp code that a particular feature is enabled. Maybe something like this: #define SCMP_FEAT_TAP ... int seccomp_feature_enable(int feature); This is a good approach, and then the blacklist can vary based on what features are enabled. -- Regards, Corey Bryant One more comment below. Adding a system call blacklist right before the vcpus starts. This filter is composed by the system calls that can't be executed after the guests are up. This list should be refined as whitelist is, with as much testing as we can do using virt-test. Signed-off-by: Eduardo Otubo ot...@linux.vnet.ibm.com --- include/sysemu/seccomp.h | 6 - qemu-seccomp.c | 64 +++- vl.c | 21 +++- 3 files changed, 77 insertions(+), 14 deletions(-) diff --git a/include/sysemu/seccomp.h b/include/sysemu/seccomp.h index 1189fa2..9dc7e52 100644 --- a/include/sysemu/seccomp.h +++ b/include/sysemu/seccomp.h @@ -15,8 +15,12 @@ #ifndef QEMU_SECCOMP_H #define QEMU_SECCOMP_H +#define WHITELIST 0 +#define BLACKLIST 1 Should these #defines be namespaced in some way, e.g. SCMP_LIST_BLACKLIST? #include seccomp.h #include qemu/osdep.h -int seccomp_start(void); +int seccomp_start(int list_type); + #endif
Re: [Qemu-devel] [PATCH 1/2] vmdk: convert error reporting
Am 10.10.2013 um 09:20 hat Fam Zheng geschrieben: Convert fprintf(stderr,... to error API by passing around errp to functions those want to report error message. There are 2 more fprintf(stderr,... remaining in read/write code path. Signed-off-by: Fam Zheng f...@redhat.com --- block/vmdk.c | 42 +- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 5d56e31..a98ad23 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -483,7 +483,7 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent) static int vmdk_open_vmfs_sparse(BlockDriverState *bs, BlockDriverState *file, - int flags) + int flags, Error **errp) { int ret; uint32_t magic; The errp parameter is unused in this function. You should probably use error_setg_errno() for the failure cases. Callers generally don't distinguish different error return codes, so converted functions could return void instead of int. @@ -514,11 +514,11 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs, } static int vmdk_open_desc_file(BlockDriverState *bs, int flags, - uint64_t desc_offset); + uint64_t desc_offset, Error **errp); static int vmdk_open_vmdk4(BlockDriverState *bs, BlockDriverState *file, - int flags) + int flags, Error **errp) { int ret; uint32_t magic; @@ -534,7 +534,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, if (header.capacity == 0) { uint64_t desc_offset = le64_to_cpu(header.desc_offset); if (desc_offset) { -return vmdk_open_desc_file(bs, flags, desc_offset 9); +return vmdk_open_desc_file(bs, flags, desc_offset 9, errp); } } @@ -663,7 +663,7 @@ static int vmdk_parse_description(const char *desc, const char *opt_name, /* Open an extent file and append to bs array */ static int vmdk_open_sparse(BlockDriverState *bs, BlockDriverState *file, -int flags) +int flags, Error **errp) { uint32_t magic; @@ -674,10 +674,10 @@ static int vmdk_open_sparse(BlockDriverState *bs, magic = be32_to_cpu(magic); switch (magic) { case VMDK3_MAGIC: -return vmdk_open_vmfs_sparse(bs, file, flags); +return vmdk_open_vmfs_sparse(bs, file, flags, errp); break; case VMDK4_MAGIC: -return vmdk_open_vmdk4(bs, file, flags); +return vmdk_open_vmdk4(bs, file, flags, errp); break; default: return -EMEDIUMTYPE; @@ -686,7 +686,7 @@ static int vmdk_open_sparse(BlockDriverState *bs, } static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, -const char *desc_file_path) + const char *desc_file_path, Error **errp) { int ret; char access[11]; @@ -748,13 +748,13 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, extent-flat_start_offset = flat_offset 9; } else if (!strcmp(type, SPARSE) || !strcmp(type, VMFSSPARSE)) { /* SPARSE extent and VMFSSPARSE extent are both COWD sparse file*/ -ret = vmdk_open_sparse(bs, extent_file, bs-open_flags); +ret = vmdk_open_sparse(bs, extent_file, bs-open_flags, errp); if (ret) { bdrv_unref(extent_file); return ret; } } else { -fprintf(stderr, +error_setg(errp, VMDK: Not supported extent type \%s\.\n, type); return -ENOTSUP; } @@ -769,7 +769,7 @@ next_line: } static int vmdk_open_desc_file(BlockDriverState *bs, int flags, - uint64_t desc_offset) + uint64_t desc_offset, Error **errp) { int ret; char *buf = NULL; @@ -798,13 +798,13 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, strcmp(ct, vmfsSparse) strcmp(ct, twoGbMaxExtentSparse) strcmp(ct, twoGbMaxExtentFlat)) { -fprintf(stderr, +error_setg(errp, VMDK: Not supported image type \%s\.\n, ct); ret = -ENOTSUP; goto exit; } s-desc_offset = 0; -ret = vmdk_parse_extents(buf, bs, bs-file-filename); +ret = vmdk_parse_extents(buf, bs, bs-file-filename, errp); exit: g_free(buf); return ret; @@ -816,10 +816,10 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, int ret; BDRVVmdkState *s = bs-opaque; -if (vmdk_open_sparse(bs,
Re: [Qemu-devel] [RFC] map 64-bit PCI devices after all possible RAM
On Wed, Oct 09, 2013 at 02:23:04PM +0200, Igor Mammedov wrote: I'm posting it to get an oppinion on one of possible approaches on where to map a hotplug memory. This patch assumes that a space for hotplug memory is located right after RamSizeOver4G region and QEMU will provide romfile to specify where it ends so that BIOS could know from what base to start 64-bit PCI devices mapping. Signed-off-by: Igor Mammedov imamm...@redhat.com Well there are two things bios does with RamSizeOver4G: determine where to map PCI devices, and fill in smbios. I wonder whether QEMU should fill smbios from qemu too, that would let us side-step the issue and just make RamSizeOver4G larger. Let's see how the ACPI patchset fares first ... --- src/fw/pciinit.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index b29db99..62f8d4e 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -18,6 +18,8 @@ #include paravirt.h // RamSize #include string.h // memset #include util.h // pci_setup +#include byteorder.h // le64_to_cpu +#include romfile.h // romfile_loadint #define PCI_DEVICE_MEM_MIN 0x1000 #define PCI_BRIDGE_IO_MIN 0x1000 @@ -764,6 +766,8 @@ static void pci_bios_map_devices(struct pci_bus *busses) { if (pci_bios_init_root_regions(busses)) { struct pci_region r64_mem, r64_pref; +u64 base64 = le64_to_cpu(romfile_loadint(etc/mem64-end, + 0x1ULL + RamSizeOver4G)); r64_mem.list.first = NULL; r64_pref.list.first = NULL; pci_region_migrate_64bit_entries(busses[0].r[PCI_REGION_TYPE_MEM], @@ -779,7 +783,7 @@ static void pci_bios_map_devices(struct pci_bus *busses) u64 align_mem = pci_region_align(r64_mem); u64 align_pref = pci_region_align(r64_pref); -r64_mem.base = ALIGN(0x1LL + RamSizeOver4G, align_mem); +r64_mem.base = ALIGN(base64, align_mem); r64_pref.base = ALIGN(r64_mem.base + sum_mem, align_pref); pcimem64_start = r64_mem.base; pcimem64_end = r64_pref.base + sum_pref; -- 1.8.3.1
Re: [Qemu-devel] [PATCH v6 2/5] hpet: enable to entitle more irq pins for hpet
On Thu, Oct 10, 2013 at 11:46:42AM +0200, Paolo Bonzini wrote: Il 10/10/2013 11:41, Michael S. Tsirkin ha scritto: Are you sure? This is not done for any other compat property. Paolo It's done if we use the property from C. See PCI_HOST_PROP_PCI_HOLE64_SIZE. You want compiler to catch errors, that's much better than a runtime failure. I agree, but I think there should be no need to use the property from C. Paolo Well this patchset does use it from C. If it's done it needs a macro.
Re: [Qemu-devel] [PATCH v2 0/6] Configure metadata overlap checks at runtime
Am 10.10.2013 um 11:09 hat Max Reitz geschrieben: This series changes the way of selecting what metadata overlap checks to perform from (currently) using a macro to using a variable contained in BDRVQcowState which can be configured at runtime through several command line options. v2: - rebased on Kevin's block branch - patch 1: affects line numbers, diff environments and one overlap check that has been removed in the meantime - patch 2: line number changes - patch 5: replaced QCOW2_OL_SNAPSHOT_TABLE by QCOW2_OL_INACTIVE_L1 in the definition of QCOW2_OL_CACHED (the former one is already a part of QCOW2_OL_CONSTANT, the latter one was missing) Thanks, applied to the block branch. Kevin
Re: [Qemu-devel] [RFC] map 64-bit PCI devices after all possible RAM
Hi, I think the simplest way to do all this is simply to tell seabios that we have more memory. seabios already programs 64 bit BARs higher than memory. Hmm? As I understand Igor just wants some address space for memory hotplug. So there wouldn't be memory there (yet). And telling seabios there is although there isn't will make seabios place wrong info into the e820 tables. Not going to fly. I think the issue is with legacy guests. E.g. if VCPU claims to support 50 bit of memory do we put high PCI memory at 1 50? If yes old guests which expect at most 40 bit will not be able to use it. Hmm. Sure such guests exist? Note this is physical address lines, not virtual address space (where you might need an additional level of pagetables to fully use it, which is not something we could expect old guests being able to handle). cheers, Gerd
Re: [Qemu-devel] [PATCH v12 5/8] module: implement module loading
Il 10/10/2013 13:26, Fam Zheng ha scritto: This patch adds loading, stamp checking and initialization of modules. The init function of dynamic module is no longer directly called as __attribute__((constructor)) in static linked version, it is called only after passed the checking of presense of stamp symbol: qemu_stamp_$(date +%s$$$RANDOM) With this, modules built from a different tree/version/configure will not be loaded. The module loading code requires gmodule-2.0. Signed-off-by: Fam Zheng f...@redhat.com --- Makefile | 3 ++ configure | 32 ++- include/qemu/module.h | 12 ++ module-common.c | 10 + rules.mak | 7 ++-- scripts/create_config | 14 +++ util/module.c | 107 +- 7 files changed, 170 insertions(+), 15 deletions(-) create mode 100644 module-common.c diff --git a/Makefile b/Makefile index a8488d6..51de298 100644 --- a/Makefile +++ b/Makefile @@ -196,6 +196,9 @@ Makefile: $(version-obj-y) $(version-lobj-y) libqemustub.a: $(stub-obj-y) libqemuutil.a: $(util-obj-y) qapi-types.o qapi-visit.o +block-modules = $(foreach o,$(block-obj-m),$(basename $(subst /,-,$o)),) NULL +util/module.o-cflags = -D'CONFIG_BLOCK_MODULES=$(block-modules)' + ## qemu-img.o: qemu-img-cmds.h diff --git a/configure b/configure index 7b8771a..dd901ab 100755 --- a/configure +++ b/configure @@ -199,6 +199,7 @@ datadir=\${prefix}/share qemu_docdir=\${prefix}/share/doc/qemu bindir=\${prefix}/bin libdir=\${prefix}/lib +moddir=\${prefix}/lib/qemu libexecdir=\${prefix}/libexec includedir=\${prefix}/include sysconfdir=\${prefix}/etc @@ -660,7 +661,8 @@ for opt do ;; --disable-debug-info) ;; - --enable-modules) modules=yes + --enable-modules) + modules=yes ;; --cpu=*) ;; @@ -685,6 +687,8 @@ for opt do ;; --libdir=*) libdir=$optarg ;; + --moddir=*) moddir=$optarg + ;; --libexecdir=*) libexecdir=$optarg ;; --includedir=*) includedir=$optarg @@ -1084,6 +1088,7 @@ echo --datadir=PATH install firmware in PATH$confsuffix echo --docdir=PATHinstall documentation in PATH$confsuffix echo --bindir=PATHinstall binaries in PATH echo --libdir=PATHinstall libraries in PATH +echo --moddir=PATHinstall modules in PATH Is moddir needed? It should always be LIBDIR/qemu. Paolo echo --sysconfdir=PATHinstall config in PATH$confsuffix echo --localstatedir=PATH install local state in PATH (set at runtime on win32) echo --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix] @@ -2291,15 +2296,19 @@ if test $mingw32 = yes; then else glib_req_ver=2.12 fi -if $pkg_config --atleast-version=$glib_req_ver gthread-2.0; then -glib_cflags=`$pkg_config --cflags gthread-2.0` -glib_libs=`$pkg_config --libs gthread-2.0` -CFLAGS=$glib_cflags $CFLAGS -LIBS=$glib_libs $LIBS -libs_qga=$glib_libs $libs_qga -else -error_exit glib-$glib_req_ver required to compile QEMU -fi + +for i in gthread-2.0 gmodule-2.0; do +if $pkg_config --atleast-version=$glib_req_ver $i; then +glib_cflags=`$pkg_config --cflags $i` +glib_libs=`$pkg_config --libs $i` +CFLAGS=$glib_cflags $CFLAGS +LIBS=$glib_libs $LIBS +libs_qga=$glib_libs $libs_qga +else +error_exit glib-$glib_req_ver required to compile QEMU +fi +done + ## # pixman support probe @@ -3660,6 +3669,7 @@ echo Install prefix$prefix echo BIOS directory`eval echo $qemu_datadir` echo binary directory `eval echo $bindir` echo library directory `eval echo $libdir` +echo module directory `eval echo $moddir` echo libexec directory `eval echo $libexecdir` echo include directory `eval echo $includedir` echo config directory `eval echo $sysconfdir` @@ -3786,6 +3796,7 @@ echo all: $config_host_mak echo prefix=$prefix $config_host_mak echo bindir=$bindir $config_host_mak echo libdir=$libdir $config_host_mak +echo moddir=$moddir $config_host_mak echo libexecdir=$libexecdir $config_host_mak echo includedir=$includedir $config_host_mak echo mandir=$mandir $config_host_mak @@ -3804,6 +3815,7 @@ echo libs_softmmu=$libs_softmmu $config_host_mak echo ARCH=$ARCH $config_host_mak +echo CONFIG_STAMP=$(date +%s$$$RANDOM) $config_host_mak if test $modules = yes; then echo CONFIG_MODULES=y $config_host_mak fi diff --git a/include/qemu/module.h b/include/qemu/module.h index c4ccd57..47b7f1d 100644 --- a/include/qemu/module.h +++ b/include/qemu/module.h @@ -14,11 +14,22 @@ #ifndef QEMU_MODULE_H #define QEMU_MODULE_H +#ifdef BUILD_DSO +void
Re: [Qemu-devel] [PATCH 10/13] Add xxmrgh/xxmrgl
On 10/9/2013 3:09 PM, Richard Henderson wrote: On 10/04/2013 06:23 AM, Tom Musta wrote: +tcg_gen_andi_i64(a0, a0, 0xul); \ +tcg_gen_shli_i64(a1, a1, 32); \ +tcg_gen_shri_i64(b0, b0, 32); \ +tcg_gen_andi_i64(b0, b0, 0xul); \ +tcg_gen_andi_i64(b1, b1, 0xul); \ +tcg_gen_or_i64(a0, a0, b0); \ +tcg_gen_or_i64(a1, a1, b1); \ +tcg_gen_mov_i64(cpu_vsrh(xT(ctx-opcode)), a0); \ +tcg_gen_mov_i64(cpu_vsrl(xT(ctx-opcode)), a1); \ Two deposit operations. r~ Richard: Thanks for the comments. I will rework this to use deposit (and also lxvw4x and xxspltw).
Re: [Qemu-devel] [RFC] map 64-bit PCI devices after all possible RAM
On Thu, Oct 10, 2013 at 02:14:16PM +0200, Gerd Hoffmann wrote: Hi, I think the simplest way to do all this is simply to tell seabios that we have more memory. seabios already programs 64 bit BARs higher than memory. Hmm? As I understand Igor just wants some address space for memory hotplug. So there wouldn't be memory there (yet). And telling seabios there is although there isn't will make seabios place wrong info into the e820 tables. Not going to fly. True. Maybe we should get some smbios stuff from qemu too. I think the issue is with legacy guests. E.g. if VCPU claims to support 50 bit of memory do we put high PCI memory at 1 50? If yes old guests which expect at most 40 bit will not be able to use it. Hmm. Sure such guests exist? I wouldn't be surprised. At least some windows guests crash if you try to tell them your system has too much physical memory (e.g. 2^48). Note this is physical address lines, not virtual address space (where you might need an additional level of pagetables to fully use it, which is not something we could expect old guests being able to handle). cheers, Gerd
Re: [Qemu-devel] [PATCH v12 0/8] Shared Library Module Support
I have a doubt about patch 5. I have placed the others in a configure branch on github, in preparation for sending a pull request once there's agreement. Paolo
[Qemu-devel] [PATCH] exec: remove qemu_safe_ram_ptr
This is not needed since the RAM list is not modified anymore by qemu_get_ram_ptr. Replace it with qemu_get_ram_block. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- exec.c | 97 +++--- 1 file changed, 28 insertions(+), 69 deletions(-) diff --git a/exec.c b/exec.c index 59920da..4148361 100644 --- a/exec.c +++ b/exec.c @@ -135,7 +135,6 @@ static PhysPageMap next_map; static void io_mem_init(void); static void memory_map_init(void); -static void *qemu_safe_ram_ptr(ram_addr_t addr); static MemoryRegion io_mem_watch; #endif @@ -675,22 +674,39 @@ CPUArchState *cpu_copy(CPUArchState *env) } #if !defined(CONFIG_USER_ONLY) +static RAMBlock *qemu_get_ram_block(ram_addr_t addr) +{ +RAMBlock *block; + +/* The list is protected by the iothread lock here. */ +block = ram_list.mru_block; +if (block addr - block-offset block-length) { +goto found; +} +QTAILQ_FOREACH(block, ram_list.blocks, next) { +if (addr - block-offset block-length) { +goto found; +} +} + +fprintf(stderr, Bad ram offset % PRIx64 \n, (uint64_t)addr); +abort(); + +found: +ram_list.mru_block = block; +return block; +} + static void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t end, uintptr_t length) { -uintptr_t start1; +RAMBlock *block; +ram_addr_t start1; -/* we modify the TLB cache so that the dirty bit will be set again - when accessing the range */ -start1 = (uintptr_t)qemu_safe_ram_ptr(start); -/* Check that we don't span multiple blocks - this breaks the - address comparisons below. */ -if ((uintptr_t)qemu_safe_ram_ptr(end - 1) - start1 -!= (end - 1) - start) { -abort(); -} +block = qemu_get_ram_block(start); +assert(block == qemu_get_ram_block(end - 1)); +start1 = (uintptr_t)block-host + (start - block-offset); cpu_tlb_reset_dirty_all(start1, length); - } /* Note: start and end must be within the same ram block. */ @@ -1319,29 +1335,6 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length) } #endif /* !_WIN32 */ -static RAMBlock *qemu_get_ram_block(ram_addr_t addr) -{ -RAMBlock *block; - -/* The list is protected by the iothread lock here. */ -block = ram_list.mru_block; -if (block addr - block-offset block-length) { -goto found; -} -QTAILQ_FOREACH(block, ram_list.blocks, next) { -if (addr - block-offset block-length) { -goto found; -} -} - -fprintf(stderr, Bad ram offset % PRIx64 \n, (uint64_t)addr); -abort(); - -found: -ram_list.mru_block = block; -return block; -} - /* Return a host pointer to ram allocated with qemu_ram_alloc. With the exception of the softmmu code in this file, this should only be used for local memory (e.g. video ram) that the device owns, @@ -1369,40 +1362,6 @@ void *qemu_get_ram_ptr(ram_addr_t addr) return block-host + (addr - block-offset); } -/* Return a host pointer to ram allocated with qemu_ram_alloc. Same as - * qemu_get_ram_ptr but do not touch ram_list.mru_block. - * - * ??? Is this still necessary? - */ -static void *qemu_safe_ram_ptr(ram_addr_t addr) -{ -RAMBlock *block; - -/* The list is protected by the iothread lock here. */ -QTAILQ_FOREACH(block, ram_list.blocks, next) { -if (addr - block-offset block-length) { -if (xen_enabled()) { -/* We need to check if the requested address is in the RAM - * because we don't want to map the entire memory in QEMU. - * In that case just map until the end of the page. - */ -if (block-offset == 0) { -return xen_map_cache(addr, 0, 0); -} else if (block-host == NULL) { -block-host = -xen_map_cache(block-offset, block-length, 1); -} -} -return block-host + (addr - block-offset); -} -} - -fprintf(stderr, Bad ram offset % PRIx64 \n, (uint64_t)addr); -abort(); - -return NULL; -} - /* Return a host pointer to guest's ram. Similar to qemu_get_ram_ptr * but takes a size argument */ static void *qemu_ram_ptr_length(ram_addr_t addr, hwaddr *size) -- 1.8.3.1
Re: [Qemu-devel] [PATCH 1/2] qcow2: Undo leaked allocations in co_writev
Am 10.10.2013 um 10:52 hat Max Reitz geschrieben: If the write request spans more than one L2 table, qcow2_alloc_cluster_offset cannot handle the required allocations atomically. This results in leaks if it allocated new clusters in any but the last L2 table touched and an error occurs in qcow2_co_writev before having established the L2 link. These non-atomic allocations were, however, indeed successful and are therefore given to the caller in the L2Meta list. If an error occurs in qcow2_co_writev and the L2Meta list is unwound, all its remaining entries are clusters whose L2 links were not yet established. Thus, all allocations in that list should be undone. Signed-off-by: Max Reitz mre...@redhat.com --- block/qcow2.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index b2489fb..6bedd5d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1017,6 +1017,13 @@ fail: while (l2meta != NULL) { QCowL2Meta *next; +/* Undo all leaked allocations */ +if (l2meta-nb_clusters != 0) { +qcow2_free_clusters(bs, l2meta-alloc_offset, +l2meta-nb_clusters s-cluster_bits, +QCOW2_DISCARD_ALWAYS); +} + if (l2meta-nb_clusters != 0) { QLIST_REMOVE(l2meta, next_in_flight); } This feels a bit risky. I think currently it does work, because qcow2_alloc_cluster_link_l2() can only return an error when it didn't update the L2 entry in the cache yet, but adding any error condition between that point and the L2Meta unwinding would result in corruption. I'm unsure, but perhaps a cluster leak is the lesser evil. Did you consider this? Do other people have an opinion on it? Also, shouldn't it be QCOW2_DISCARD_OTHER? Kevin
Re: [Qemu-devel] [PATCH 11/13] Add xxsel
On 10/9/2013 3:13 PM, Richard Henderson wrote: On 10/04/2013 06:24 AM, Tom Musta wrote: +tcg_gen_and_i64(b, b, c); +tcg_gen_not_i64(c, c); +tcg_gen_and_i64(a, a, c); tcg_gen_andc_i64. +#define GEN_XXSEL() \ +GEN_XXSEL_ROW(0x00) \ +GEN_XXSEL_ROW(0x01) \ Why bother with defining GEN_XXSEL when its only used once? Surely just put the rows there. OTOH, this does suggest that we could do with a better way to decode the instructions, because this is ugly... r~ Yeah ... it isn't very pretty. There was precedent for this (see, for example, rldcl). And the decoding logic very much wants to use instruction bits 26:30 and 21:25 as opc2 and opc3 respectively. Perhaps I could inject a handler for opcode 60 that would handle the VSX map a little more gracefully. Is your concern aesthetic? Memory consumption? And do you feel this is a showstopper or something that could be addressed later?
Re: [Qemu-devel] [PATCH v12 5/8] module: implement module loading
On Thu, 10/10 14:16, Paolo Bonzini wrote: Il 10/10/2013 13:26, Fam Zheng ha scritto: This patch adds loading, stamp checking and initialization of modules. The init function of dynamic module is no longer directly called as __attribute__((constructor)) in static linked version, it is called only after passed the checking of presense of stamp symbol: qemu_stamp_$(date +%s$$$RANDOM) With this, modules built from a different tree/version/configure will not be loaded. The module loading code requires gmodule-2.0. Signed-off-by: Fam Zheng f...@redhat.com --- Makefile | 3 ++ configure | 32 ++- include/qemu/module.h | 12 ++ module-common.c | 10 + rules.mak | 7 ++-- scripts/create_config | 14 +++ util/module.c | 107 +- 7 files changed, 170 insertions(+), 15 deletions(-) create mode 100644 module-common.c diff --git a/Makefile b/Makefile index a8488d6..51de298 100644 --- a/Makefile +++ b/Makefile @@ -196,6 +196,9 @@ Makefile: $(version-obj-y) $(version-lobj-y) libqemustub.a: $(stub-obj-y) libqemuutil.a: $(util-obj-y) qapi-types.o qapi-visit.o +block-modules = $(foreach o,$(block-obj-m),$(basename $(subst /,-,$o)),) NULL +util/module.o-cflags = -D'CONFIG_BLOCK_MODULES=$(block-modules)' + ## qemu-img.o: qemu-img-cmds.h diff --git a/configure b/configure index 7b8771a..dd901ab 100755 --- a/configure +++ b/configure @@ -199,6 +199,7 @@ datadir=\${prefix}/share qemu_docdir=\${prefix}/share/doc/qemu bindir=\${prefix}/bin libdir=\${prefix}/lib +moddir=\${prefix}/lib/qemu libexecdir=\${prefix}/libexec includedir=\${prefix}/include sysconfdir=\${prefix}/etc @@ -660,7 +661,8 @@ for opt do ;; --disable-debug-info) ;; - --enable-modules) modules=yes + --enable-modules) + modules=yes ;; --cpu=*) ;; @@ -685,6 +687,8 @@ for opt do ;; --libdir=*) libdir=$optarg ;; + --moddir=*) moddir=$optarg + ;; --libexecdir=*) libexecdir=$optarg ;; --includedir=*) includedir=$optarg @@ -1084,6 +1088,7 @@ echo --datadir=PATH install firmware in PATH$confsuffix echo --docdir=PATHinstall documentation in PATH$confsuffix echo --bindir=PATHinstall binaries in PATH echo --libdir=PATHinstall libraries in PATH +echo --moddir=PATHinstall modules in PATH Is moddir needed? It should always be LIBDIR/qemu. Hmm, basically an analogue to bindir and libdir. I'm not sure why wasn't that libdir/bindir always be ${prefix}/lib and ${prefix}/bin as well. So why are they needed? AFAICT it is not a problem to drop it, if you insist. Fam Paolo echo --sysconfdir=PATHinstall config in PATH$confsuffix echo --localstatedir=PATH install local state in PATH (set at runtime on win32) echo --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix] @@ -2291,15 +2296,19 @@ if test $mingw32 = yes; then else glib_req_ver=2.12 fi -if $pkg_config --atleast-version=$glib_req_ver gthread-2.0; then -glib_cflags=`$pkg_config --cflags gthread-2.0` -glib_libs=`$pkg_config --libs gthread-2.0` -CFLAGS=$glib_cflags $CFLAGS -LIBS=$glib_libs $LIBS -libs_qga=$glib_libs $libs_qga -else -error_exit glib-$glib_req_ver required to compile QEMU -fi + +for i in gthread-2.0 gmodule-2.0; do +if $pkg_config --atleast-version=$glib_req_ver $i; then +glib_cflags=`$pkg_config --cflags $i` +glib_libs=`$pkg_config --libs $i` +CFLAGS=$glib_cflags $CFLAGS +LIBS=$glib_libs $LIBS +libs_qga=$glib_libs $libs_qga +else +error_exit glib-$glib_req_ver required to compile QEMU +fi +done + ## # pixman support probe @@ -3660,6 +3669,7 @@ echo Install prefix$prefix echo BIOS directory`eval echo $qemu_datadir` echo binary directory `eval echo $bindir` echo library directory `eval echo $libdir` +echo module directory `eval echo $moddir` echo libexec directory `eval echo $libexecdir` echo include directory `eval echo $includedir` echo config directory `eval echo $sysconfdir` @@ -3786,6 +3796,7 @@ echo all: $config_host_mak echo prefix=$prefix $config_host_mak echo bindir=$bindir $config_host_mak echo libdir=$libdir $config_host_mak +echo moddir=$moddir $config_host_mak echo libexecdir=$libexecdir $config_host_mak echo includedir=$includedir $config_host_mak echo mandir=$mandir $config_host_mak @@ -3804,6 +3815,7 @@ echo libs_softmmu=$libs_softmmu $config_host_mak echo ARCH=$ARCH
[Qemu-devel] [PATCH v2 1/2] vmdk: convert error code to use errp
Convert fprintf(stderr,... and standardize error messages: Remove a few local_error's and use errp. Remove VMDK: or Vmdk: prefixes in error message and fix to upper case. Signed-off-by: Fam Zheng f...@redhat.com --- block/vmdk.c | 116 +++ 1 file changed, 61 insertions(+), 55 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 5d56e31..4f8ae77 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -331,8 +331,7 @@ static int vmdk_reopen_prepare(BDRVReopenState *state, assert(state-bs != NULL); if (queue == NULL) { -error_set(errp, ERROR_CLASS_GENERIC_ERROR, - No reopen queue for VMDK extents); +error_setg(errp, No reopen queue for VMDK extents); goto exit; } @@ -391,22 +390,23 @@ static int vmdk_add_extent(BlockDriverState *bs, int64_t l1_offset, int64_t l1_backup_offset, uint32_t l1_size, int l2_size, uint64_t cluster_sectors, - VmdkExtent **new_extent) + VmdkExtent **new_extent, + Error **errp) { VmdkExtent *extent; BDRVVmdkState *s = bs-opaque; if (cluster_sectors 0x20) { /* 0x20 * 512Bytes = 1GB for one cluster is unrealistic */ -error_report(invalid granularity, image may be corrupt); -return -EINVAL; +error_setg(errp, Invalid granularity, image may be corrupt); +return -EFBIG; } if (l1_size 512 * 1024 * 1024) { /* Although with big capacity and small l1_entry_sectors, we can get a * big l1_size, we don't want unbounded value to allocate the table. * Limit it to 512M, which is 16PB for default cluster and L2 table * size */ -error_report(L1 size too big); +error_setg(errp, L1 size too big); return -EFBIG; } @@ -438,7 +438,8 @@ static int vmdk_add_extent(BlockDriverState *bs, return 0; } -static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent) +static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent, +Error **errp) { int ret; int l1_size, i; @@ -447,10 +448,13 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent) l1_size = extent-l1_size * sizeof(uint32_t); extent-l1_table = g_malloc(l1_size); ret = bdrv_pread(extent-file, -extent-l1_table_offset, -extent-l1_table, -l1_size); + extent-l1_table_offset, + extent-l1_table, + l1_size); if (ret 0) { +error_setg_errno(errp, -ret, + Could not read l1 table from extent '%s', + extent-file-filename); goto fail_l1; } for (i = 0; i extent-l1_size; i++) { @@ -460,10 +464,13 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent) if (extent-l1_backup_table_offset) { extent-l1_backup_table = g_malloc(l1_size); ret = bdrv_pread(extent-file, -extent-l1_backup_table_offset, -extent-l1_backup_table, -l1_size); + extent-l1_backup_table_offset, + extent-l1_backup_table, + l1_size); if (ret 0) { +error_setg_errno(errp, -ret, + Could not read l1 backup table from extent '%s', + extent-file-filename); goto fail_l1b; } for (i = 0; i extent-l1_size; i++) { @@ -483,7 +490,7 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent) static int vmdk_open_vmfs_sparse(BlockDriverState *bs, BlockDriverState *file, - int flags) + int flags, Error **errp) { int ret; uint32_t magic; @@ -492,6 +499,9 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs, ret = bdrv_pread(file, sizeof(magic), header, sizeof(header)); if (ret 0) { +error_setg_errno(errp, -ret, + Could not read header from file '%s', + file-filename); return ret; } ret = vmdk_add_extent(bs, file, false, @@ -501,11 +511,12 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs, le32_to_cpu(header.l1dir_size), 4096, le32_to_cpu(header.granularity), - extent); + extent, + errp); if (ret 0) { return ret; } -ret = vmdk_init_tables(bs, extent); +ret = vmdk_init_tables(bs, extent, errp); if (ret) {
[Qemu-devel] [PATCH v2 0/2] vmdk: convert error reporting
The first patch converts fprintf(stderr,... to error_setg with errp, and fixes style of error message texts. The second patch checks the compatibility of zeroed_grain flag and flat type and reports error if both are true. v2: [01] More conversion of error messages, also catch error from bdrv_{pread,pwrite} with error_setg_errno. Fam Zheng (2): vmdk: convert error code to use errp vmdk: refuse enabling zeroed grain with flat images block/vmdk.c | 120 --- 1 file changed, 65 insertions(+), 55 deletions(-) -- 1.8.3.1
[Qemu-devel] [PATCH v2 2/2] vmdk: refuse enabling zeroed grain with flat images
This is a header flag and we needs sparse for the header. Signed-off-by: Fam Zheng f...@redhat.com --- block/vmdk.c | 4 1 file changed, 4 insertions(+) diff --git a/block/vmdk.c b/block/vmdk.c index 4f8ae77..90340eb 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1664,6 +1664,10 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options, error_setg(errp, Flat image can't have backing file); return -ENOTSUP; } +if (flat zeroed_grain) { +error_setg(errp, Flat image can't enable zeroed grain); +return -ENOTSUP; +} if (backing_file) { BlockDriverState *bs = bdrv_new(); ret = bdrv_open(bs, backing_file, NULL, 0, NULL, errp); -- 1.8.3.1
Re: [Qemu-devel] [RFC] map 64-bit PCI devices after all possible RAM
Hi, I think the issue is with legacy guests. E.g. if VCPU claims to support 50 bit of memory do we put high PCI memory at 1 50? If yes old guests which expect at most 40 bit will not be able to use it. Hmm. Sure such guests exist? I wouldn't be surprised. At least some windows guests crash if you try to tell them your system has too much physical memory (e.g. 2^48). Ok, so there is not really a way around making the location configurable. The size isn't needed, qemu can handle this on it's own. Guess we can just go with Igor's approach then. etc/mem64-end is a pretty bad name to say please map 64bit pci bars here though. cheers, Gerd
Re: [Qemu-devel] [PATCH] block: Improve driver whitelist checks
On Thu, 10/10 11:57, Kevin Wolf wrote: The main intent of this patch is to consolidate the whitelist checks to a single point in the code instead of spreading it everywhere. This adds a nicer error message for read-only whitelisting, too, in places where it was still missing. The patch also contains a bonus bug fix: By finding the format first in bdrv_open() and then independently checking against the whitelist only later, we avoid the case that use of a non-whitelisted format results in probing rather than an error message. Previously, this could happen when using the driver=... option. Signed-off-by: Kevin Wolf kw...@redhat.com --- block.c| 10 +++--- blockdev.c | 8 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/block.c b/block.c index beea027..84c0eac 100644 --- a/block.c +++ b/block.c @@ -769,7 +769,11 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file, bs-read_only = !(open_flags BDRV_O_RDWR); if (use_bdrv_whitelist !bdrv_is_whitelisted(drv, bs-read_only)) { -error_setg(errp, Driver '%s' is not whitelisted, drv-format_name); +error_setg(errp, + !bs-read_only bdrv_is_whitelisted(drv, true) +? Driver '%s' can only be used for read-only devices +: Driver '%s' is not whitelisted, + drv-format_name); return -ENOTSUP; } @@ -881,7 +885,7 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename, /* Find the right block driver */ drvname = qdict_get_try_str(options, driver); if (drvname) { -drv = bdrv_find_whitelisted_format(drvname, !(flags BDRV_O_RDWR)); +drv = bdrv_find_format(drvname); if (!drv) { error_setg(errp, Unknown driver '%s', drvname); } @@ -1123,7 +1127,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, /* Find the right image format driver */ drvname = qdict_get_try_str(options, driver); if (drvname) { -drv = bdrv_find_whitelisted_format(drvname, !(flags BDRV_O_RDWR)); +drv = bdrv_find_format(drvname); qdict_del(options, driver); } diff --git a/blockdev.c b/blockdev.c index 92029d8..5f3cece 100644 --- a/blockdev.c +++ b/blockdev.c @@ -468,13 +468,9 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts, return NULL; } -drv = bdrv_find_whitelisted_format(buf, ro); +drv = bdrv_find_format(buf); if (!drv) { -if (!ro bdrv_find_whitelisted_format(buf, !ro)) { -error_report('%s' can be only used as read-only device., buf); -} else { -error_report('%s' invalid format, buf); -} +error_report('%s' invalid format, buf); return NULL; } } This is much cleaner now. Thanks. Reviewed-by: Fam Zheng f...@redhat.com
Re: [Qemu-devel] [PATCH] Use qemu-project.org domain name
On 10 October 2013 18:39, Stefan Hajnoczi stefa...@redhat.com wrote: --- a/.gitmodules +++ b/.gitmodules @@ -1,27 +1,27 @@ [submodule roms/vgabios] path = roms/vgabios - url = git://git.qemu.org/vgabios.git/ + url = git://git.qemu-project.org/vgabios.git/ I agree we need to make this change -- but do you know if an existing checkout with the submodule checked out will automatically do the Right Thing on git update or if manual intervention is necessary ? thanks -- PMM
Re: [Qemu-devel] [PATCH 1/2] qcow2: Undo leaked allocations in co_writev
On 2013-10-10 14:26, Kevin Wolf wrote: Am 10.10.2013 um 10:52 hat Max Reitz geschrieben: If the write request spans more than one L2 table, qcow2_alloc_cluster_offset cannot handle the required allocations atomically. This results in leaks if it allocated new clusters in any but the last L2 table touched and an error occurs in qcow2_co_writev before having established the L2 link. These non-atomic allocations were, however, indeed successful and are therefore given to the caller in the L2Meta list. If an error occurs in qcow2_co_writev and the L2Meta list is unwound, all its remaining entries are clusters whose L2 links were not yet established. Thus, all allocations in that list should be undone. Signed-off-by: Max Reitz mre...@redhat.com --- block/qcow2.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index b2489fb..6bedd5d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1017,6 +1017,13 @@ fail: while (l2meta != NULL) { QCowL2Meta *next; +/* Undo all leaked allocations */ +if (l2meta-nb_clusters != 0) { +qcow2_free_clusters(bs, l2meta-alloc_offset, +l2meta-nb_clusters s-cluster_bits, +QCOW2_DISCARD_ALWAYS); +} + if (l2meta-nb_clusters != 0) { QLIST_REMOVE(l2meta, next_in_flight); } This feels a bit risky. I think currently it does work, because qcow2_alloc_cluster_link_l2() can only return an error when it didn't update the L2 entry in the cache yet, but adding any error condition between that point and the L2Meta unwinding would result in corruption. I'm unsure, but perhaps a cluster leak is the lesser evil. Did you consider this? Do other people have an opinion on it? What error conditions are there which can occur between qcow2_alloc_cluster_link_l2 and the L2Meta unwinding? If all qcow2_alloc_cluster_link_l2 calls are successful, the list is empty and the while loop either goes into another iteration or the function returns successfully (without any further need to unwind the list). If some call fails, all previous (successful) calls have already been removed from the list, therefore the unwinding only affects L2Meta request with failed calls to qcow2_alloc_cluster_link_l2 (or ones where that function wasn't called at all). If the currently implied that this will turn out bad if there is a new error condition between a successful call to qcow2_alloc_cluster_link_l2 and the removal of the L2Meta request from the list: Yes, that's true, of course. However, as you've said, currently, there is no such condition; and I don't see why it should be introduced. The sole purpose of the list seems to be (to me) to execute qcow2_alloc_cluster_link_l2 on every of its elements. Thus, as soon as qcow2_alloc_cluster_link_l2 is successful, the corresponding request should be removed from the list. So, in case you do agree that it currently works fine, I would not consider it risky; if this patch is applied and some time in the future anything introduces a goto fail between qcow2_alloc_cluster_link_l2 and l2_meta = next, this patch would simply have to make sure that qcow2_free_clusters isn't called in this case. In the probably very unlikely case all my previous assumptions and conclusions were true, I'd just add a comment in the qcow2_alloc_cluster_link_l2 loop informing about this case (“If you add a goto fail here, make sure to pay attention” or something along these lines). Also, shouldn't it be QCOW2_DISCARD_OTHER? I'm always unsure about the discard flags. ;-) I try to follow the rule of “use the specific type (or ‘other’) for freeing ‘out of the blue’, but use ‘always’ if it's just a very recent allocation that is being undone again”. I'd gladly accept better recommendations. ;-) Max
[Qemu-devel] [RfC PATCH] e820: pass high memory too.
We have a fw_cfg entry to pass e820 entries from qemu to the firmware. Today it's used to pass reservations only. This patch makes qemu pass entries for RAM too. This allows to pass RAM sizes larger than 1TB to the firmware and it will also allow to pass non-contignous memory ramges should we decide to implement that some day, say for our virtual numa nodes. Obviously this needs some extra care to not break existing firware. SeaBIOS loads the entries and happily adds them without looking at the type. Which is problematic for memory below 4g as this will overwrite reservations added for bios memory etc. For memory above 4g it works just fine, seabios will merge the entry derived from cmos with the one loaded from fw_cfg. OVMF doesn't look at the fw_cfg e820 table. coreboot doesn't look at the fw_cfg e820 table. Cc: Andrea Arcangeli aarca...@redhat.com Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/i386/pc.c | 8 1 file changed, 8 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 0c313fe..ec5508b 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1134,12 +1134,20 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory, memory_region_init_alias(ram_below_4g, NULL, ram-below-4g, ram, 0, below_4g_mem_size); memory_region_add_subregion(system_memory, 0, ram_below_4g); +if (0) { +/* + * Ideally we should do that too, but that would ruin the e820 + * reservations added by seabios before initializing fw_cfg. + */ +e820_add_entry(0, below_4g_mem_size, E820_RAM); +} if (above_4g_mem_size 0) { ram_above_4g = g_malloc(sizeof(*ram_above_4g)); memory_region_init_alias(ram_above_4g, NULL, ram-above-4g, ram, below_4g_mem_size, above_4g_mem_size); memory_region_add_subregion(system_memory, 0x1ULL, ram_above_4g); +e820_add_entry(0x1ULL, above_4g_mem_size, E820_RAM); } -- 1.8.3.1
[Qemu-devel] [PATCH 0/2] Improve -device command line help some more
From: Markus Armbruster arm...@redhat.com Marcel's recent improvements (commit dbd94f8..125ee0e) go in the right direction, but there are issues (see PATCH 1/2), and I find the resulting help output still hard to read. This series redoes the help printing part of Marcel's series. Result looks like this (moxie picked as example for brevity): $ qemu-system-moxie -device help Controller/Bridge/Hub devices: name usb-host, bus usb-bus name usb-hub, bus usb-bus Storage devices: name scsi-block, bus SCSI, desc SCSI block device passthrough name scsi-cd, bus SCSI, desc virtual SCSI CD-ROM name scsi-disk, bus SCSI, desc virtual SCSI disk or CD-ROM (legacy) name scsi-generic, bus SCSI, desc pass through generic scsi device (/dev/sg*) name scsi-hd, bus SCSI, desc virtual SCSI disk Input devices: name isa-serial, bus ISA name usb-kbd, bus usb-bus name usb-mouse, bus usb-bus name usb-tablet, bus usb-bus Misc devices: name smbus-eeprom, bus i2c-bus name usb-redir, bus usb-bus Additionally, info qdm is again just like device_add help with no-user devices included. Markus Armbruster (2): Mostly revert qemu-help: Sort devices by logical functionality qdev-monitor: Group device_add help and info qdm by category include/hw/qdev-core.h | 16 -- qdev-monitor.c | 85 -- 2 files changed, 47 insertions(+), 54 deletions(-) -- 1.8.1.4
[Qemu-devel] [PATCH 1/2] Mostly revert qemu-help: Sort devices by logical functionality
From: Markus Armbruster arm...@redhat.com This reverts most of commit 3d1237fb2ab4edb926c717767bb5e31d6053a7c5. The commit claims to sort the output of -device help by functionality rather than alphabetical. Issues: * The output was unsorted before, not alphabetically sorted. Misleading, but harmless enough. * The commit doesn't just sort the output of -device help as it claims, it adds categories to each line of -device help, and it prints devices once per category. In particular, devices without a category aren't shown anymore. Maybe such devices should not exist, but they do. Regression. * Categories are also added to the output of info qdm. Silent change, not nice. Output remains unsorted, unlike -device help. I'm going to reimplement the feature we actually want, without the warts. Reverting the flawed commit first should make it easier to review. However, I can't revert it completely, since DeviceClass member categories has been put to use. So leave that part in. Signed-off-by: Markus Armbruster arm...@redhat.com --- include/hw/qdev-core.h | 16 qdev-monitor.c | 48 +--- 2 files changed, 9 insertions(+), 55 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index a62f231..e191ca0 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -30,22 +30,6 @@ typedef enum DeviceCategory { DEVICE_CATEGORY_MAX } DeviceCategory; -static inline const char *qdev_category_get_name(DeviceCategory category) -{ -static const char *category_names[DEVICE_CATEGORY_MAX] = { -[DEVICE_CATEGORY_BRIDGE] = Controller/Bridge/Hub, -[DEVICE_CATEGORY_USB] = USB, -[DEVICE_CATEGORY_STORAGE] = Storage, -[DEVICE_CATEGORY_NETWORK] = Network, -[DEVICE_CATEGORY_INPUT] = Input, -[DEVICE_CATEGORY_DISPLAY] = Display, -[DEVICE_CATEGORY_SOUND] = Sound, -[DEVICE_CATEGORY_MISC]= Misc, -}; - -return category_names[category]; -}; - typedef int (*qdev_initfn)(DeviceState *dev); typedef int (*qdev_event)(DeviceState *dev); typedef void (*qdev_resetfn)(DeviceState *dev); diff --git a/qdev-monitor.c b/qdev-monitor.c index 410cdcb..e5adf6c 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -75,27 +75,24 @@ static bool qdev_class_has_alias(DeviceClass *dc) return (qdev_class_get_alias(dc) != NULL); } -static void qdev_print_class_devinfo(DeviceClass *dc) +static void qdev_print_devinfo(ObjectClass *klass, void *opaque) { -DeviceCategory category; +DeviceClass *dc; +bool *show_no_user = opaque; + +dc = (DeviceClass *)object_class_dynamic_cast(klass, TYPE_DEVICE); -if (!dc) { +if (!dc || (show_no_user !*show_no_user dc-no_user)) { return; } -error_printf(name \%s\, object_class_get_name(OBJECT_CLASS(dc))); +error_printf(name \%s\, object_class_get_name(klass)); if (dc-bus_type) { error_printf(, bus %s, dc-bus_type); } if (qdev_class_has_alias(dc)) { error_printf(, alias \%s\, qdev_class_get_alias(dc)); } -error_printf(, categories); -for (category = 0; category DEVICE_CATEGORY_MAX; ++category) { -if (test_bit(category, dc-categories)) { -error_printf( \%s\, qdev_category_get_name(category)); -} -} if (dc-desc) { error_printf(, desc \%s\, dc-desc); } @@ -105,15 +102,6 @@ static void qdev_print_class_devinfo(DeviceClass *dc) error_printf(\n); } -static void qdev_print_devinfo(ObjectClass *klass, void *opaque) -{ -DeviceClass *dc; - -dc = (DeviceClass *)object_class_dynamic_cast(klass, TYPE_DEVICE); - -qdev_print_class_devinfo(dc); -} - static int set_property(const char *name, const char *value, void *opaque) { DeviceState *dev = opaque; @@ -151,21 +139,6 @@ static const char *find_typename_by_alias(const char *alias) return NULL; } -static void qdev_print_category_devices(DeviceCategory category) -{ -DeviceClass *dc; -GSList *list, *curr; - -list = object_class_get_list(TYPE_DEVICE, false); -for (curr = list; curr; curr = g_slist_next(curr)) { -dc = (DeviceClass *)object_class_dynamic_cast(curr-data, TYPE_DEVICE); -if (!dc-no_user test_bit(category, dc-categories)) { -qdev_print_class_devinfo(dc); -} -} -g_slist_free(list); -} - int qdev_device_help(QemuOpts *opts) { const char *driver; @@ -174,11 +147,8 @@ int qdev_device_help(QemuOpts *opts) driver = qemu_opt_get(opts, driver); if (driver is_help_option(driver)) { -DeviceCategory category; -for (category = 0; category DEVICE_CATEGORY_MAX; ++category) { -qdev_print_category_devices(category); -} - +bool show_no_user = false; +object_class_foreach(qdev_print_devinfo, TYPE_DEVICE, false, show_no_user); return 1; } -- 1.8.1.4
[Qemu-devel] [PATCH 2/2] qdev-monitor: Group device_add help and info qdm by category
From: Markus Armbruster arm...@redhat.com Output is a long, unsorted list. Not very helpful. Print one list per device category instead, with a header line identifying the category, plus a list of uncategorized devices. Print each list in case-insenitive alphabetical order. Devices with multiple categories are listed multiple times. Signed-off-by: Markus Armbruster arm...@redhat.com --- qdev-monitor.c | 67 ++ 1 file changed, 53 insertions(+), 14 deletions(-) diff --git a/qdev-monitor.c b/qdev-monitor.c index e5adf6c..a02c925 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -75,18 +75,9 @@ static bool qdev_class_has_alias(DeviceClass *dc) return (qdev_class_get_alias(dc) != NULL); } -static void qdev_print_devinfo(ObjectClass *klass, void *opaque) +static void qdev_print_devinfo(DeviceClass *dc) { -DeviceClass *dc; -bool *show_no_user = opaque; - -dc = (DeviceClass *)object_class_dynamic_cast(klass, TYPE_DEVICE); - -if (!dc || (show_no_user !*show_no_user dc-no_user)) { -return; -} - -error_printf(name \%s\, object_class_get_name(klass)); +error_printf(name \%s\, object_class_get_name(OBJECT_CLASS(dc))); if (dc-bus_type) { error_printf(, bus %s, dc-bus_type); } @@ -102,6 +93,55 @@ static void qdev_print_devinfo(ObjectClass *klass, void *opaque) error_printf(\n); } +static gint devinfo_cmp(gconstpointer a, gconstpointer b) +{ +return strcasecmp(object_class_get_name((ObjectClass *)a), + object_class_get_name((ObjectClass *)b)); +} + +static void qdev_print_devinfos(bool show_no_user) +{ +static const char *cat_name[DEVICE_CATEGORY_MAX + 1] = { +[DEVICE_CATEGORY_BRIDGE] = Controller/Bridge/Hub, +[DEVICE_CATEGORY_USB] = USB, +[DEVICE_CATEGORY_STORAGE] = Storage, +[DEVICE_CATEGORY_NETWORK] = Network, +[DEVICE_CATEGORY_INPUT] = Input, +[DEVICE_CATEGORY_DISPLAY] = Display, +[DEVICE_CATEGORY_SOUND] = Sound, +[DEVICE_CATEGORY_MISC]= Misc, +[DEVICE_CATEGORY_MAX] = Uncategorized, +}; +GSList *list, *elt; +int i; +bool cat_printed; + +list = g_slist_sort(object_class_get_list(TYPE_DEVICE, false), +devinfo_cmp); + +for (i = 0; i = DEVICE_CATEGORY_MAX; i++) { +cat_printed = false; +for (elt = list; elt; elt = elt-next) { +DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt-data, + TYPE_DEVICE); +if ((i DEVICE_CATEGORY_MAX + ? !test_bit(i, dc-categories) + : !bitmap_empty(dc-categories, DEVICE_CATEGORY_MAX)) +|| (!show_no_user dc-no_user)) { +continue; +} +if (!cat_printed) { +error_printf(%s%s devices:\n, i ? \n : , + cat_name[i]); +cat_printed = true; +} +qdev_print_devinfo(dc); +} +} + +g_slist_free(list); +} + static int set_property(const char *name, const char *value, void *opaque) { DeviceState *dev = opaque; @@ -147,8 +187,7 @@ int qdev_device_help(QemuOpts *opts) driver = qemu_opt_get(opts, driver); if (driver is_help_option(driver)) { -bool show_no_user = false; -object_class_foreach(qdev_print_devinfo, TYPE_DEVICE, false, show_no_user); +qdev_print_devinfos(false); return 1; } @@ -587,7 +626,7 @@ void do_info_qtree(Monitor *mon, const QDict *qdict) void do_info_qdm(Monitor *mon, const QDict *qdict) { -object_class_foreach(qdev_print_devinfo, TYPE_DEVICE, false, NULL); +qdev_print_devinfos(true); } int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data) -- 1.8.1.4
Re: [Qemu-devel] [PATCH] Use qemu-project.org domain name
qemu-project.org isn't a good domain name, and sound a bit strange, i think personally.:) Maybe we can apply one new domain name such as kemu.org, etc. On Thu, Oct 10, 2013 at 5:39 PM, Stefan Hajnoczi stefa...@redhat.com wrote: qemu.org is held by a third-party and no core community contributor has access to the DNS configuration. This leaves the website exposed to outages due to DNS issues or IP address changes. For example, if the web server IP address needs to change we cannot guarantee qemu.org will point to it! The newer qemu-project.org domain name is owned by Anthony Liguori anth...@codemonkey.ws. You can confirm this by querying the whois information. Also note that the #qemu IRC channel topic already references qemu-project.org. Short of having a dedicated legal entity to hold the domain name on behalf of the community, qemu-project.org seems like the safest bet. Let's replace references to qemu.org with qemu-project.org. Signed-off-by: Stefan Hajnoczi stefa...@redhat.com --- This sprang from another email thread where qemu.org URLs were posted. I realized that there are still many references in the source tree. .gitmodules| 14 +++--- Changelog | 2 +- MAINTAINERS| 8 README | 2 +- docs/qmp/README| 2 +- docs/rdma.txt | 2 +- pc-bios/README | 2 +- qemu.nsi | 2 +- scripts/get_maintainer.pl | 2 +- scripts/qmp/qemu-ga-client | 2 +- version.rc | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.gitmodules b/.gitmodules index d7e3f3c..45e51e7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,27 +1,27 @@ [submodule roms/vgabios] path = roms/vgabios - url = git://git.qemu.org/vgabios.git/ + url = git://git.qemu-project.org/vgabios.git/ [submodule roms/seabios] path = roms/seabios - url = git://git.qemu.org/seabios.git/ + url = git://git.qemu-project.org/seabios.git/ [submodule roms/SLOF] path = roms/SLOF - url = git://git.qemu.org/SLOF.git + url = git://git.qemu-project.org/SLOF.git [submodule roms/ipxe] path = roms/ipxe - url = git://git.qemu.org/ipxe.git + url = git://git.qemu-project.org/ipxe.git [submodule roms/openbios] path = roms/openbios - url = git://git.qemu.org/openbios.git + url = git://git.qemu-project.org/openbios.git [submodule roms/qemu-palcode] path = roms/qemu-palcode url = git://github.com/rth7680/qemu-palcode.git [submodule roms/sgabios] path = roms/sgabios - url = git://git.qemu.org/sgabios.git + url = git://git.qemu-project.org/sgabios.git [submodule pixman] path = pixman url = git://anongit.freedesktop.org/pixman [submodule dtc] path = dtc - url = git://git.qemu.org/dtc.git + url = git://git.qemu-project.org/dtc.git diff --git a/Changelog b/Changelog index 13eebef..1249b8a 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,6 @@ This file documents changes for QEMU releases 0.12 and earlier. For changelog information for later releases, see -http://wiki.qemu.org/ChangeLog or look at the git history for +http://wiki.qemu-project.org/ChangeLog or look at the git history for more detailed information. diff --git a/MAINTAINERS b/MAINTAINERS index 5c3c70c..7466f96 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -855,21 +855,21 @@ Stable branches --- Stable 1.0 L: qemu-sta...@nongnu.org -T: git git://git.qemu.org/qemu-stable-1.0.git +T: git git://git.qemu-project.org/qemu-stable-1.0.git S: Orphan Stable 0.15 L: qemu-sta...@nongnu.org M: Andreas Färber afaer...@suse.de -T: git git://git.qemu.org/qemu-stable-0.15.git +T: git git://git.qemu-project.org/qemu-stable-0.15.git S: Supported Stable 0.14 L: qemu-sta...@nongnu.org -T: git git://git.qemu.org/qemu-stable-0.14.git +T: git git://git.qemu-project.org/qemu-stable-0.14.git S: Orphan Stable 0.10 L: qemu-sta...@nongnu.org -T: git git://git.qemu.org/qemu-stable-0.10.git +T: git git://git.qemu-project.org/qemu-stable-0.10.git S: Orphan diff --git a/README b/README index c77d126..c7c990d 100644 --- a/README +++ b/README @@ -1,3 +1,3 @@ -Read the documentation in qemu-doc.html or on http://wiki.qemu.org +Read the documentation in qemu-doc.html or on http://wiki.qemu-project.org - QEMU team diff --git a/docs/qmp/README b/docs/qmp/README index 85c4bc1..f6a3a03 100644 --- a/docs/qmp/README +++ b/docs/qmp/README @@ -84,4 +84,4 @@ Please, refer to the qapi-schema.json file for a complete command reference. QMP wiki page - -http://wiki.qemu.org/QMP +http://wiki.qemu-project.org/QMP diff --git a/docs/rdma.txt b/docs/rdma.txt index 8d1e003..2aca63b 100644 --- a/docs/rdma.txt +++ b/docs/rdma.txt @@
Re: [Qemu-devel] [RFC] map 64-bit PCI devices after all possible RAM
On Thu, 10 Oct 2013 14:42:07 +0200 Gerd Hoffmann kra...@redhat.com wrote: Hi, I think the issue is with legacy guests. E.g. if VCPU claims to support 50 bit of memory do we put high PCI memory at 1 50? If yes old guests which expect at most 40 bit will not be able to use it. Hmm. Sure such guests exist? I wouldn't be surprised. At least some windows guests crash if you try to tell them your system has too much physical memory (e.g. 2^48). Ok, so there is not really a way around making the location configurable. The size isn't needed, qemu can handle this on it's own. Guess we can just go with Igor's approach then. etc/mem64-end is a pretty bad name to say please map 64bit pci bars here though. reasoning bind was to tell BIOS where RAM ends and let it decide what to do with this information. But we could do other way around and use etc/pci-info that was proposed earlier by Michael, it is already committed into QEMU and provides start/end of 32/64-bit PCI windows in QEMU view. We could use pci-info.w64.start as base for 64-bit bars. If it's good enough, I'll amend my patch to use it. cheers, Gerd
Re: [Qemu-devel] [RFC] map 64-bit PCI devices after all possible RAM
On Thu, 10 Oct 2013 15:21:32 +0300 Michael S. Tsirkin m...@redhat.com wrote: On Thu, Oct 10, 2013 at 02:14:16PM +0200, Gerd Hoffmann wrote: Hi, I think the simplest way to do all this is simply to tell seabios that we have more memory. seabios already programs 64 bit BARs higher than memory. Hmm? As I understand Igor just wants some address space for memory hotplug. So there wouldn't be memory there (yet). And telling seabios there is although there isn't will make seabios place wrong info into the e820 tables. Not going to fly. True. Maybe we should get some smbios stuff from qemu too. I think the issue is with legacy guests. E.g. if VCPU claims to support 50 bit of memory do we put high PCI memory at 1 50? If yes old guests which expect at most 40 bit will not be able to use it. Hmm. Sure such guests exist? I wouldn't be surprised. At least some windows guests crash if you try to tell them your system has too much physical memory (e.g. 2^48). confirmed, the same happened when memory device was mapped too high, can't recall windows version tough. Note this is physical address lines, not virtual address space (where you might need an additional level of pagetables to fully use it, which is not something we could expect old guests being able to handle). cheers, Gerd
Re: [Qemu-devel] [RFC] map 64-bit PCI devices after all possible RAM
Hi, Guess we can just go with Igor's approach then. etc/mem64-end is a pretty bad name to say please map 64bit pci bars here though. reasoning bind was to tell BIOS where RAM ends and let it decide what to do with this information. But we could do other way around and use etc/pci-info that was proposed earlier by Michael, it is already committed into QEMU and provides start/end of 32/64-bit PCI windows in QEMU view. We could use pci-info.w64.start as base for 64-bit bars. We need only the single value from pci-info, I'd suggest to drop pci-info in favor of a file you can read using romfile_loadint. cheers, Gerd
Re: [Qemu-devel] [Xen-devel] Hvmloader: Add _STA for PCI hotplug slots
Hi, Not enough tests are done in system based the patch. Windows OS can support PCI hot plug/unplug, PCI hot plug/unplug will cause qemu crashes in Redhat6.3/5.8. After reading the ACPI spec, we modify the patch: Index: mk_dsdt.c === --- mk_dsdt.c (revision 90666) +++ mk_dsdt.c (working copy) @@ -437,7 +437,7 @@ indent(); printf(B0EJ, 32,\n); pop_block(); -stmt(OperationRegion, SRMV, SystemIO, 0xae0c, 0x04); +stmt(OperationRegion, SRMV, SystemIO, 0xae00, 0x04); push_block(Field, SRMV, DWordAcc, NoLock, WriteAsZeros); indent(); printf(RMV, 32,\n); pop_block(); @@ -451,10 +451,10 @@ } pop_block(); push_block(Method, _STA, 0);{ push_block(If, And(RMV, ShiftLeft(1, %#06x)), slot); - stmt(Return, 0x1F); + stmt(Return, 0x0F); pop_block(); push_block(Else, NULL); - stmt(Return, 0x1E); + stmt(Return, 0x00); pop_block(); };pop_block(); stmt(Name, _SUN, %i, slot); based on this patch, PCI hot plug/unplug is supported in Redhat5.8/win2008, but the problem still exists in Redhat6.3. More support are needed, Expecting your reply. Best Regards, -Gonglei -Original Message- From: Fabio Fantoni [mailto:fabio.fant...@m2r.biz] Sent: Tuesday, October 08, 2013 8:58 PM To: Gonglei (Arei) Cc: Konrad Rzeszutek Wilk; anthony.per...@citrix.com; Stefano Stabellini; Hanweidong (Randy); Yanqiangjun; Luonengjun; qemu-devel@nongnu.org; xen-de...@lists.xen.org; Gaowei (UVP); Huangweidong (Hardware) Subject: Re: [Xen-devel] Hvmloader: Add _STA for PCI hotplug slots Il 29/09/2013 02:30, Gonglei (Arei) ha scritto: -Original Message- From: Konrad Rzeszutek Wilk [mailto:konrad.w...@oracle.com] Sent: Saturday, September 28, 2013 5:43 AM To: Gonglei (Arei); anthony.per...@citrix.com; Stefano Stabellini Cc: xen-de...@lists.xen.org; Hanweidong (Randy); Yanqiangjun; Luonengjun; qemu-devel@nongnu.org; Gaowei (UVP); Huangweidong (Hardware) Subject: Re: [Xen-devel] Hvmloader: Add _STA for PCI hotplug slots On Fri, Sep 27, 2013 at 06:29:20AM +, Gonglei (Arei) wrote: Hi, Hey, (CCing Stefano and Anthony). In Xen platform, after using upstream qemu, the all of pci devices will show hotplug in the windows guest. In this situation, the windows guest may occur blue screen when VM' user click the icon of VGA card for trying unplug VGA card. However, we don't hope VM's user can do such dangerous operation, and showing all pci devices inside the guest OS is unfriendly. In addition, I find the traditional qemu have not this problem, and KVM also. Is there any news about this patch please? On the KVM platform, the seabios will read the RMV bits of pci slot (according the 0xae08 I/O port register), then modify the SSDT table. The key steps as follows: In Seabios: #define PCI_RMV_BASE 0xae0c// 0xae08 I/O port register static void* build_ssdt(void) { ... // build Device object for each slot u32 rmvc_pcrm = inl(PCI_RMV_BASE); ... } In upstream Qemu, read 0xae0c I/O port register function: static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) { ... case PCI_RMV_BASE - PCI_HOTPLUG_ADDR: val = s-pci0_hotplug_enable; break; } s-pci0_hotplug_enable is set by the follow function: static void piix4_update_hotplug(PIIX4PMState *s) { ... s-pci0_hotplug_enable = ~0; s-pci0_slot_device_present = 0; QTAILQ_FOREACH_SAFE(kid, bus-children, sibling, next) { DeviceState *qdev = kid-child; PCIDevice *pdev = PCI_DEVICE(qdev); PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pdev); int slot = PCI_SLOT(pdev-devfn); //setting by PCIDeviceClass *k-no_hotplug if (pc-no_hotplug) { s-pci0_hotplug_enable = ~(1U slot); } s-pci0_slot_device_present |= (1U slot); } } But, on the XEN platform, ACPI DSDT tables is produced by the hvmloader, more details in this patch: http://xen.1045712.n5.nabble.com/xen-unstable-hvmloader-acpi-dsdt-Fix-PCI- hotplug-with-the-new-qemu-xen-td4947152.html # Node ID 1a912ce93b506a185b54fd97986214e6eff8a0bc # Parent 6bc03e22f921aadfa7e5cebe92100cb01377947d hvmloader/acpi/dsdt: Fix PCI hotplug with the new qemu-xen. oddly enough you did not CC the author of said patch? I am doing that for you. That's my mistake, thank you so much! The ACPI PIIX4 device in QEMU upstream as not the same behavior to handle PCI hotplug. This patch introduce the necessary change to the DSDT ACPI table to behave as expceted by the new QEMU. To switch to this