hello evryone,who can give me a detail explain of the qemu code of the online snapshot?THX
At 2013-11-06 11:10:10,address@hidden wrote:
>Send Qemu-devel mailing list submissions to
> address@hidden
>
>To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.nongnu.org/mailman/listinfo/qemu-devel
>or, via email, send a message with subject or body 'help' to
> address@hidden
>
>You can reach the person managing the list at
> address@hidden
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of Qemu-devel digest..."
>
>
>Today's Topics:
>
> 1. [PATCH for-1.7 2/2] tests: fix memleak in error path test for
> input visitor (Wenchao Xia)
> 2. [PATCH for-1.7 0/2] fix qapi mem leaks (Wenchao Xia)
> 3. [PATCH for-1.7 1/2] qapi: fix memleak by adding implict
> struct functions in dealloc visitor (Wenchao Xia)
> 4. Re: [PATCH RFC 03/10] qapi script: check correctness of
> discriminator values in union (Wenchao Xia)
> 5. Re: [PATCH] RFC: powerpc: add PVR compatibility check
> (Paul Mackerras)
> 6. [PATCH V6 0/5] Refine and export backing file loop check (Xu Wang)
> 7. [PATCH V6 1/5] block/qemu-img: Refine and export infinite
> loop checking in collect_image_info_list() (Xu Wang)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Wed, 6 Nov 2013 02:35:51 +0800
>From: Wenchao Xia <address@hidden>
>To: address@hidden
>Cc: address@hidden, Wenchao Xia <address@hidden>,
> address@hidden, address@hidden
>Subject: [Qemu-devel] [PATCH for-1.7 2/2] tests: fix memleak in error
> path test for input visitor
>Message-ID:
> <address@hidden>
>
>Signed-off-by: Wenchao Xia <address@hidden>
>Reviewed-by: Eric Blake <address@hidden>
>Cc: address@hidden
>---
> tests/test-qmp-input-visitor.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
>diff --git a/tests/test-qmp-input-visitor.c b/tests/test-qmp-input-visitor.c
>index 0beb8fb..1e1c6fa 100644
>--- a/tests/test-qmp-input-visitor.c
>+++ b/tests/test-qmp-input-visitor.c
>@@ -604,6 +604,7 @@ static void test_visitor_in_errors(TestInputVisitorData *data,
> g_assert(error_is_set(&errp));
> g_assert(p->string == NULL);
>
>+ error_free(errp);
> g_free(p->string);
> g_free(p);
> }
>--
>1.7.1
>
>
>
>
>------------------------------
>
>Message: 2
>Date: Wed, 6 Nov 2013 02:35:49 +0800
>From: Wenchao Xia <address@hidden>
>To: address@hidden
>Cc: address@hidden, Wenchao Xia <address@hidden>,
> address@hidden, address@hidden
>Subject: [Qemu-devel] [PATCH for-1.7 0/2] fix qapi mem leaks
>Message-ID:
> <address@hidden>
>
>The bugfix patches are picked up from RFC series:
>http://lists.nongnu.org/archive/html/qemu-devel/2013-11/msg00363.html
>
>Wenchao Xia (2):
> qapi: fix memleak by adding implict struct functions in dealloc visitor
> tests: fix memleak in error path test for input visitor
>
> qapi/qapi-dealloc-visitor.c | 20 ++++++++++++++++++++
> tests/test-qmp-input-visitor.c | 1 +
> 2 files changed, 21 insertions(+), 0 deletions(-)
>
>
>
>
>------------------------------
>
>Message: 3
>Date: Wed, 6 Nov 2013 02:35:50 +0800
>From: Wenchao Xia <address@hidden>
>To: address@hidden
>Cc: address@hidden, Wenchao Xia <address@hidden>,
> address@hidden, address@hidden
>Subject: [Qemu-devel] [PATCH for-1.7 1/2] qapi: fix memleak by adding
> implict struct functions in dealloc visitor
>Message-ID:
> <address@hidden>
>
>Otherwise member "base" is leaked in a qapi_free_STRUCTURE() call.
>
>Signed-off-by: Wenchao Xia <address@hidden>
>Reviewed-by: Eric Blake <address@hidden>
>Cc: address@hidden
>---
> qapi/qapi-dealloc-visitor.c | 20 ++++++++++++++++++++
> 1 files changed, 20 insertions(+), 0 deletions(-)
>
>diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c
>index 1334de3..dc53545 100644
>--- a/qapi/qapi-dealloc-visitor.c
>+++ b/qapi/qapi-dealloc-visitor.c
>@@ -76,6 +76,24 @@ static void qapi_dealloc_end_struct(Visitor *v, Error **errp)
> }
> }
>
>+static void qapi_dealloc_start_implicit_struct(Visitor *v,
>+ void **obj,
>+ size_t size,
>+ Error **errp)
>+{
>+ QapiDeallocVisitor *qov = to_qov(v);
>+ qapi_dealloc_push(qov, obj);
>+}
>+
>+static void qapi_dealloc_end_implicit_struct(Visitor *v, Error **errp)
>+{
>+ QapiDeallocVisitor *qov = to_qov(v);
>+ void **obj = qapi_dealloc_pop(qov);
>+ if (obj) {
>+ g_free(*obj);
>+ }
>+}
>+
> static void qapi_dealloc_start_list(Visitor *v, const char *name, Error **errp)
> {
> QapiDeallocVisitor *qov = to_qov(v);
>@@ -162,6 +180,8 @@ QapiDeallocVisitor *qapi_dealloc_visitor_new(void)
>
> v->visitor.start_struct = qapi_dealloc_start_struct;
> v->visitor.end_struct = qapi_dealloc_end_struct;
>+ v->visitor.start_implicit_struct = qapi_dealloc_start_implicit_struct;
>+ v->visitor.end_implicit_struct = qapi_dealloc_end_implicit_struct;
> v->visitor.start_list = qapi_dealloc_start_list;
> v->visitor.next_list = qapi_dealloc_next_list;
> v->visitor.end_list = qapi_dealloc_end_list;
>--
>1.7.1
>
>
>
>
>------------------------------
>
>Message: 4
>Date: Wed, 06 Nov 2013 11:02:38 +0800
>From: Wenchao Xia <address@hidden>
>To: Eric Blake <address@hidden>, address@hidden
>Cc: address@hidden, address@hidden, address@hidden,
> address@hidden
>Subject: Re: [Qemu-devel] [PATCH RFC 03/10] qapi script: check
> correctness of discriminator values in union
>Message-ID: <address@hidden>
>Content-Type: text/plain; charset=UTF-8; format=flowed
>
>? 2013/11/5 21:25, Eric Blake ??:
>> On 11/04/2013 05:37 PM, Wenchao Xia wrote:
>>> It will check whether the values specfied are wrotten correctly when
>>
>> s/specfied/specified/
>> s/wrotten/written/
>>
>>> discriminator is a pre-defined enum type, which help check whether the
>>> schema is in good form.
>>>
>>> It is allowed that, not every value in enum is used, so do not check
>>
>> s/that,/that/
>>
>>> that case.
>>
>> Why do you allow partial coverage? That feels like an accident waiting
>> to happen. Does the user get a sane error message if they request an
>> enum value that wasn't mapped to a union branch? I think it would be
>> wiser to mandate that if the discriminator is an enum, then the union
>> must cover all values of the enum.
>>
> abort() will be called in qapi-visit.c, it is OK for output visitor,
>but bad for input visitor since user input may trigger it. I think
>change abort() to error_set() could solve the problem, then we allow
>map part of enum value.
>
>>> +
>>> +# Return the descriminator enum define, if discriminator is specified in
>>
>> s/descriminator/discriminator/
>>
>>> +# @expr and it is a pre-defined enum type
>>> +def descriminator_find_enum_define(expr):
>>
>> s/descriminator/discriminator/ - and fix all callers
>>
>>> + discriminator = expr.get('discriminator')
>>> + base = expr.get('base')
>>> +
>>> + # Only support discriminator when base present
>>> + if not (discriminator and base):
>>> + return None
>>> +
>>> + base_fields = find_base_fields(base)
>>> +
>>> + if not base_fields:
>>> + sys.stderr.write("Base '%s' is not a valid type\n"
>>> + % base)
>>> + sys.exit(1)
>>> +
>>> + descriminator_type = base_fields.get(discriminator)
>>
>> s/descriminator/discriminator/
>>
>
>
>
>
>------------------------------
>
>Message: 5
>Date: Wed, 6 Nov 2013 14:02:37 +1100
>From: Paul Mackerras <address@hidden>
>To: Andreas F?rber <address@hidden>
>Cc: Alexey Kardashevskiy <address@hidden>, qemu-ppc
> <address@hidden>, Alexander Graf <address@hidden>, Anthony Liguori
> <address@hidden>, QEMU Developers <address@hidden>
>Subject: Re: [Qemu-devel] [PATCH] RFC: powerpc: add PVR compatibility
> check
>Message-ID: <address@hidden>
>Content-Type: text/plain; charset=iso-8859-1
>
>On Tue, Nov 05, 2013 at 05:16:33PM +0100, Andreas F?rber wrote:
>> Am 05.11.2013 07:05, schrieb Alexander Graf:
>> >
>> >
>> > Am 05.11.2013 um 05:00 schrieb Paul Mackerras <address@hidden>:
>> >
>> >> On Mon, Nov 04, 2013 at 10:05:58AM +0100, Alexander Graf wrote:
>> >>>
>> >>> Yeah, we really need to check that guest vpcu == host vcpu for HV KVM.
>> >>
>> >> In general I agree, but the one difficulty I see is that a check for
>> >> exact equality will interact badly with qemu's habit of picking a
>> >> specific processor version when the user specifies something general
>> >> like "POWER7". So if the user does -cpu POWER7 on a machine with
>> >> (for example) a POWER7 v2.1 processor, but qemu arbitrarily picks the
>> >> PVR for POWER7 v2.3, then it will fail, which will be completely
>> >> puzzling to the user -- "I asked for POWER7, and it is a POWER7,
>> >> what's the problem??".
>> >>
>> >> Maybe if the user asks for a non-specific processor type, and the
>> >> host's PVR matches the request, then qemu should take the host's PVR
>> >> rather than just picking some arbitrary processor version.
>> >
>> > Yup.
>>
>> But then it's no longer generally reproducible: "POWER7" won't be
>> "POWER7" on another machine.
>
>There aren't any observable differences between POWER7 versions that
>have been sold to customers, as far as I have been able to ascertain
>(other than the PVR value, of course). So this whole business of
>carefully distinguishing between POWER7 v2.2 and POWER7 v2.3 is
>largely a waste of time as far as I can see.
>
>I admit that in the past we (IBM) did a silly thing in releasing the
>POWER5+ v3.0 chip with some architecturally new features (64k pages
>and some other MMU changes). That was a mistake and I don't think
>we'll do it again.
>
>I think the default assumption should be that versions of a given IBM
>POWER chip (identified by the upper 16 bits of the PVR) are
>architecturally identical, and behaviourally identical at the level
>at which QEMU models the chip. Differences between chips would
>normally be limited to bug fixes and performance improvements. Then
>we just need a way to cope with POWER5+ v3.0.
>
>> One thing I original did iirc was to hide the aliases from QMP. You can
>> always do stupid things on the command line and then we can blame you,
>> but if libvirt and upper layers don't offer "POWER7" to the end user
>> then we don't need to worry about the average user misinterpreting its
>> semantics.
>
>Given that the only difference between POWER7 v2.2 and POWER7 v2.3
>(say) will be which set of host systems you get an error on, there
>doesn't seem to me to be a lot of point.
>
>Paul.
>
>
>
>------------------------------
>
>Message: 6
>Date: Tue, 5 Nov 2013 22:09:16 -0500
>From: Xu Wang <address@hidden>
>To: address@hidden
>Cc: address@hidden, address@hidden, address@hidden, Xu Wang
> <address@hidden>, address@hidden,
> address@hidden
>Subject: [Qemu-devel] [PATCH V6 0/5] Refine and export backing file
> loop check
>Message-ID:
> <address@hidden>
>
>If there is loop exists in the backing file chain, many problems
>could be caused by it, such as no response and segment fault during
>system boot. Hence stopping backing file loop appear is very necessary.
>These patches refine and export loop checking function from collect_image_
>info_list() to block.c and build a independent function named bdrv_
>backing_file_loop_check(). Backing file loop checking is added before
>image created, before change backing file and before system boot.
>
>Updates from V5:
> 1. Simplify the function of loop checking (Just filename comparation.
> Thanks Eric's suggestion).
> 2. Delete WIN32 platform support (There is no need to this patch now).
> 3. Adjust position of backing file loop checking (calling checking function
> before change happen).
> 4. Function name updates and comments description fix.
>
>Updates from V4:
> 1. Add backing file loop check in bdrv_new_open().
> 2. Adjust open file logic of collect_image_info_list() (bdrv_new_open()
> is called only once when opening the whole chain).
> 3. Remove redundant brackets in lnk file check logic.
> 4. Add error output in bdrv_img_create().
> 5. Remove MAX_PATH_LEN to use PATH_MAX instead.
>
>Updates from V3:
> 1. Comments fix for function bdrv_backing_file_loop_check().
> 2. Add ret check for fseek()/fread() in get_lnk_target_file().
> 3. Add limit of shortcuts filename length reading during comparing.
> 4. Add error_report() in driv_init().
> 5. Remove redundant loop check in qcow2/qed_change_backing_file().
>
>Updates from V2:
> 1. Removed parameter @chain from bdrv_backing_file_loop_check()
> 2. Comments and format fix, all patches were checked by checkpatch.pl
> 3. Fixed *bs leak.
> 4. Improved logic of .lnk file recognization.
> 5. Add filename lenth limit check in while()
> 6. Changed get_win_inode() to get_inode() and move all inode get method
> into it to make logic more simpler.
> 7. Added value of @fmt as suggested.
> 8. Added backing file loop check in qcow2.c/qed.c
>
>Xu Wang (5):
> block/qemu-img: Refine and export infinite loop checking in
> collect_image_info_list()
> qemu-img: Add infinite loop checking in bdrv_new_open()
> block: Add check infinite loop in bdrv_img_create()
> block: Add backing file loop check in change_backing_file()
> blockdev: Add infinite loop check in drive_init()
>
> block.c | 130 ++++++++++++++++++++++++++++++++++++++++++++++++--
> blockdev.c | 6 +++
> include/block/block.h | 4 ++
> qemu-img.c | 52 ++++++++++----------
> 4 files changed, 162 insertions(+), 30 deletions(-)
>
>--
>1.8.1.4
>
>
>
>
>------------------------------
>
>Message: 7
>Date: Tue, 5 Nov 2013 22:09:17 -0500
>From: Xu Wang <address@hidden>
>To: address@hidden
>Cc: address@hidden, address@hidden, address@hidden, Xu Wang
> <address@hidden>, address@hidden,
> address@hidden
>Subject: [Qemu-devel] [PATCH V6 1/5] block/qemu-img: Refine and export
> infinite loop checking in collect_image_info_list()
>Message-ID:
> <address@hidden>
>
>If there is a loop in the backing file chain, it could cause problems
>such as no response or a segfault during system boot. Hence detecting a
>backing file loop is necessary. This patch extracts the loop check from
>collect_image_info_list() in block.c into independent functions
>bdrv_backing_chain_okay() and bdrv_image_create_okay().
>
>Signed-off-by: Xu Wang <address@hidden>
>---
> block.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++
> include/block/block.h | 4 ++
> qemu-img.c | 44 ++++++++-----------
> 3 files changed, 139 insertions(+), 26 deletions(-)
>
>diff --git a/block.c b/block.c
>index 58efb5b..3443117 100644
>--- a/block.c
>+++ b/block.c
>@@ -4490,6 +4490,123 @@ bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie *cookie)
> bs->total_time_ns[cookie->type] += get_clock() - cookie->start_time_ns;
> }
>
>+static gboolean str_equal_func(gconstpointer a, gconstpointer b)
>+{
>+ return strcmp(a, b) == 0;
>+}
>+
>+static bool file_chain_loop_check(GHashTable *filenames, const char *filename,
>+ const char *fmt) {
>+ BlockDriverState *bs;
>+ BlockDriver *drv;
>+ char fbuf[1024];
>+ int ret;
>+ Error *local_err = NULL;
>+
>+ while (filename && (filename[0] != '\0')) {
>+ if (g_hash_table_lookup_extended(filenames, filename, NULL, NULL)) {
>+ error_report("Backing file '%s' creates an infinite loop.",
>+ filename);
>+ return true;
>+ }
>+ g_hash_table_insert(filenames, (gpointer)filename, NULL);
>+
>+ bs = bdrv_new("image");
>+
>+ if (fmt) {
>+ drv = bdrv_find_format(fmt);
>+ if (!drv) {
>+ error_report("Unknown file format '%s'", fmt);
>+ bdrv_delete(bs);
>+ return true;
>+ }
>+ } else {
>+ drv = NULL;
>+ }
>+
>+ ret = bdrv_open(bs, filename, NULL,
>+ BDRV_O_CACHE_WB | BDRV_O_NO_BACKING, drv, &local_err);
>+ if (ret < 0) {
>+ error_report("Could not open '%s': %s", filename,
>+ error_get_pretty(local_err));
>+ error_free(local_err);
>+ local_err = NULL;
>+ return true;
>+ }
>+
>+ bdrv_get_backing_filename(bs, fbuf, sizeof(fbuf));
>+ filename = fbuf;
>+ fmt = NULL;
>+
>+ bdrv_unref(bs);
>+ }
>+
>+ return false;
>+}
>+
>+/**
>+ * Check backing file chain if there is a loop in it.
>+ *
>+ * @filename: topmost image filename of backing file chain.
>+ * @fmt: topmost image format of backing file chain(may be NULL to autodetect).
>+ *
>+ * Returns: true for backing file loop or error happened, false for no loop.
>+ */
>+bool bdrv_backing_chain_okay(const char *filename, const char *fmt) {
>+ GHashTable *filenames;
>+
>+ if (filename == NULL || filename[0] == '\0') {
>+ return true;
>+ }
>+
>+ filenames = g_hash_table_new_full(g_str_hash, str_equal_func, NULL, NULL);
>+
>+ if (file_chain_loop_check(filenames, filename, fmt)) {
>+ goto err;
>+ }
>+
>+ g_hash_table_destroy(filenames);
>+ return true;
>+
>+err:
>+ g_hash_table_destroy(filenames);
>+ return false;
>+}
>+
>+/**
>+ * Check if there is loop exists in the backing file chain and if there will
>+ * be loop occur after backing file chain updated or new image created.
>+ *
>+ * @filename: the image filename to be created.
>+ * @backing_file: topmost image filename of backing file chain.
>+ * @backing_fmt: topmost image format (may be NULL to autodetect).
>+ *
>+ * Returns: true for backing file loop or error happened, false for no loop.
>+ */
>+bool bdrv_new_chain_okay(const char *filename, const char *backing_file,
>+ const char *backing_fmt) {
>+ GHashTable *filenames;
>+
>+ if (backing_file == NULL || backing_file[0] == '\0') {
>+ return true;
>+ }
>+
>+ filenames = g_hash_table_new_full(g_str_hash, str_equal_func, NULL, NULL);
>+
>+ g_hash_table_insert(filenames, (gpointer)filename, NULL);
>+
>+ if (file_chain_loop_check(filenames, backing_file, backing_fmt)) {
>+ goto err;
>+ }
>+
>+ g_hash_table_destroy(filenames);
>+ return true;
>+
>+err:
>+ g_hash_table_destroy(filenames);
>+ return false;
>+}
>+
> void bdrv_img_create(const char *filename, const char *fmt,
> const char *base_filename, const char *base_fmt,
> char *options, uint64_t img_size, int flags,
>diff --git a/include/block/block.h b/include/block/block.h
>index 3560deb..0945c09 100644
>--- a/include/block/block.h
>+++ b/include/block/block.h
>@@ -378,6 +378,10 @@ int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
> int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf,
> int64_t pos, int size);
>
>+bool bdrv_backing_chain_okay(const char *filename, const char *fmt);
>+bool bdrv_new_chain_okay(const char *filename, const char *backing_file,
>+ const char *backing_fmt);
>+
> void bdrv_img_create(const char *filename, const char *fmt,
> const char *base_filename, const char *base_fmt,
> char *options, uint64_t img_size, int flags,
>diff --git a/qemu-img.c b/qemu-img.c
>index bf3fb4f..d5ec45b 100644
>--- a/qemu-img.c
>+++ b/qemu-img.c
>@@ -1641,11 +1641,6 @@ static void dump_human_image_info_list(ImageInfoList *list)
> }
> }
>
>-static gboolean str_equal_func(gconstpointer a, gconstpointer b)
>-{
>- return strcmp(a, b) == 0;
>-}
>-
> /**
> * Open an image file chain and return an ImageInfoList
> *
>@@ -1663,30 +1658,24 @@ static ImageInfoList *collect_image_info_list(const char *filename,
> bool chain)
> {
> ImageInfoList *head = NULL;
>+ BlockDriverState *bs;
>+ ImageInfoList *elem;
> ImageInfoList **last = &head;
>- GHashTable *filenames;
>+ ImageInfo *info;
> Error *err = NULL;
>+ int flags = BDRV_O_FLAGS;
>
>- filenames = g_hash_table_new_full(g_str_hash, str_equal_func, NULL, NULL);
>-
>- while (filename) {
>- BlockDriverState *bs;
>- ImageInfo *info;
>- ImageInfoList *elem;
>-
>- if (g_hash_table_lookup_extended(filenames, filename, NULL, NULL)) {
>- error_report("Backing file '%s' creates an infinite loop.",
>- filename);
>- goto err;
>- }
>- g_hash_table_insert(filenames, (gpointer)filename, NULL);
>+ if (!chain) {
>+ flags |= BDRV_O_NO_BACKING;
>+ }
>
>- bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_NO_BACKING,
>- false, false);
>- if (!bs) {
>- goto err;
>- }
>+ bs = bdrv_new_open(filename, fmt, flags,
>+ false, false);
>+ if (!bs) {
>+ goto err;
>+ }
>
>+ while (filename) {
> bdrv_query_image_info(bs, &info, &err);
> if (error_is_set(&err)) {
> error_report("%s", error_get_pretty(err));
>@@ -1711,14 +1700,17 @@ static ImageInfoList *collect_image_info_list(const char *filename,
> if (info->has_backing_filename_format) {
> fmt = info->backing_filename_format;
> }
>+
>+ if (filename) {
>+ bs = bdrv_find_backing_image(bs, filename);
>+ }
> }
> }
>- g_hash_table_destroy(filenames);
>+
> return head;
>
> err:
> qapi_free_ImageInfoList(head);
>- g_hash_table_destroy(filenames);
> return NULL;
> }
>
>--
>1.8.1.4
>
>
>
>
>------------------------------
>
>_______________________________________________
>Qemu-devel mailing list
>address@hidden
>https://lists.nongnu.org/mailman/listinfo/qemu-devel
>
>
>End of Qemu-devel Digest, Vol 128, Issue 93
>*******************************************