From: "Daniel P. Berrange" <berrange@redhat.com>
To: Programmingkid <programmingkidx@gmail.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"John Snow" <jsnow@redhat.com>, "Jeff Cody" <jcody@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"qemu-devel qemu-devel" <qemu-devel@nongnu.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH v2] qdev-monitor.c: Add device id generation
Date: Fri, 28 Aug 2015 09:58:06 +0100 [thread overview]
Message-ID: <20150828085806.GJ28526@redhat.com> (raw)
In-Reply-To: <F62DF2C5-8522-431B-B352-9B0DECE5A561@gmail.com>
On Thu, Aug 27, 2015 at 07:14:28PM -0400, Programmingkid wrote:
> Add device ID generation to each device if an ID isn't given.
>
> An auto-generated ID will begin with an underscore character. This will
> distinguish it from user-made ID's.
>
> An user-made ID cannot begin with an underscore, so there is no
> problem of collisions with auto-generated ID's.
>
> A management program like libvirt should have no problems with this
> patch since the names for ID's it gives do not start with an underscore.
>
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>
> ---
> qdev-monitor.c | 17 ++++++++---------
> 1 files changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/qdev-monitor.c b/qdev-monitor.c
> index f9e2d62..a9beb6d 100644
> --- a/qdev-monitor.c
> +++ b/qdev-monitor.c
> @@ -574,18 +574,17 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
> id = qemu_opts_id(opts);
> if (id) {
> dev->id = id;
> + } else { /* create an ID for a device if none is provided */
> + static uint64_t deviceIDCount;
> + char *deviceIDString;
> +
> + /* Add an underscore to show this ID is auto-generated */
> + deviceIDString = g_strdup_printf("_%" PRIu64, deviceIDCount++);
> + dev->id = (const char *) deviceIDString;
The ID namespace is global to QOM, but this counter is scoped to the
qdev code, so we should have a further prefix, in case other bits of
code that also use QOM need to have auto-generated IDs.
IOW I think we should use
deviceIDString = g_strdup_printf("_qdev%" PRIu64, deviceIDCount++);
> }
>
> - if (dev->id) {
> - object_property_add_child(qdev_get_peripheral(), dev->id,
> - OBJECT(dev), NULL);
> - } else {
> - static int anon_count;
> - gchar *name = g_strdup_printf("device[%d]", anon_count++);
> - object_property_add_child(qdev_get_peripheral_anon(), name,
> + object_property_add_child(qdev_get_peripheral(), dev->id,
> OBJECT(dev), NULL);
> - g_free(name);
> - }
It looks like this is removing the only use of the /machine/peripheral-anon
part of the tre, so if we do this, then we should remove the refernces to
peripheral-anon from the rest of the codebase. Alternatively we could keep
devices with auto-generated IDs under /peripheral-anon, but I don't really
see much point. The only reason this was separated was to avoid the
auto-generated path name clashing with a user provided name, but we avoid
that now by using an underscore. So we might as well just kill off the
/peripheral-anon part of the tree and leave just /peripheral
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
prev parent reply other threads:[~2015-08-28 8:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 23:14 [Qemu-devel] [PATCH v2] qdev-monitor.c: Add device id generation Programmingkid
2015-08-28 8:58 ` Daniel P. Berrange [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150828085806.GJ28526@redhat.com \
--to=berrange@redhat.com \
--cc=afaerber@suse.de \
--cc=armbru@redhat.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=programmingkidx@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.