From: Yang Zhong <yang.zhong@intel.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: eduardo@habkost.net, yang.zhong@intel.com, lin.a.yang@intel.com,
qemu-devel@nongnu.org, pbonzini@redhat.com,
haibin.huang@intel.com
Subject: Re: [PATCH] sgx: Move sgx object from /machine/unattached to /machine
Date: Thu, 13 Jan 2022 15:05:12 +0800 [thread overview]
Message-ID: <20220113070512.GB14771@yangzhon-Virtual> (raw)
In-Reply-To: <Yd6pV+6kdfLNQRnA@redhat.com>
Hi Daniel,
On Wed, Jan 12, 2022 at 10:11:35AM +0000, Daniel P. Berrangé wrote:
> On Wed, Jan 12, 2022 at 11:55:17AM -0500, Yang Zhong wrote:
> > When Libvirt start, it get the vcpu's unavailable-features from
> > /machine/unattached/device[0] path by qom-get command, but in SGX
> > guest, since the sgx-epc virtual device is initialized before VCPU
> > creation(virtual sgx need set the virtual EPC info in the cpuid). This
> > /machine/unattached/device[0] is occupied by sgx-epc device, which
> > fail to get the unvailable-features from /machine/unattached/device[0].
>
> If libvirt decides to enable SGX in a VM, then surely it knows
> that it should just query /machine/unattached/device[1] to get
> the CPU features instead. Why do we need to do anything in QEMU ?
>
I listed two solutions in the Qemu or Libvirt before:
https://lists.nongnu.org/archive/html/qemu-devel/2021-11/msg05670.html
This time, I posted this patch and hope to have a talk for this issue.
If Libvirt side should handle this, I will drop this patch and inform
them to do this. Thanks!
> >
> > This patch make one new /machine/sgx object to avoid this issue.
> > (qemu) qom-list /machine/unattached/
> > device[0] (child<host-x86_64-cpu>)
> >
> > (qemu) qom-list /machine/sgx
> > device[0] (child<sgx-epc>)
> >
> > Signed-off-by: Yang Zhong <yang.zhong@intel.com>
> > ---
> > hw/core/qdev.c | 12 ++++++++++--
> > 1 file changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> > index 84f3019440..4154eef0d8 100644
> > --- a/hw/core/qdev.c
> > +++ b/hw/core/qdev.c
> > @@ -497,7 +497,7 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
> > NamedClockList *ncl;
> > Error *local_err = NULL;
> > bool unattached_parent = false;
> > - static int unattached_count;
> > + static int unattached_count, sgx_count;
> >
> > if (dev->hotplugged && !dc->hotpluggable) {
> > error_setg(errp, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj));
> > @@ -509,7 +509,15 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
> > goto fail;
> > }
> >
> > - if (!obj->parent) {
> > + if (!obj->parent && !strcmp(object_get_typename(obj), "sgx-epc")) {
> > + gchar *name = g_strdup_printf("device[%d]", sgx_count++);
> > +
> > + object_property_add_child(container_get(qdev_get_machine(),
> > + "/sgx"),
> > + name, obj);
> > + unattached_parent = true;
> > + g_free(name);
>
> The qdev.c file is part of our generic object code. It should not
> contain any code that is tied to very specific object types like
> this.
Okay, thanks!
Yang
>
> > + } else if (!obj->parent) {
> > gchar *name = g_strdup_printf("device[%d]", unattached_count++);
> >
> > object_property_add_child(container_get(qdev_get_machine(),
>
> Regards,
> Daniel
> --
> |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org -o- https://fstop138.berrange.com :|
> |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
prev parent reply other threads:[~2022-01-13 7:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-12 16:55 [PATCH] sgx: Move sgx object from /machine/unattached to /machine Yang Zhong
2022-01-12 10:11 ` Daniel P. Berrangé
2022-01-12 10:16 ` Peter Maydell
2022-01-12 10:24 ` Daniel P. Berrangé
2022-01-13 7:05 ` Yang Zhong [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=20220113070512.GB14771@yangzhon-Virtual \
--to=yang.zhong@intel.com \
--cc=berrange@redhat.com \
--cc=eduardo@habkost.net \
--cc=haibin.huang@intel.com \
--cc=lin.a.yang@intel.com \
--cc=pbonzini@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).