[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] sgx: Move sgx object from /machine/unattached to /machine

From: Yang Zhong
Subject: [PATCH] sgx: Move sgx object from /machine/unattached to /machine
Date: Wed, 12 Jan 2022 11:55:17 -0500

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].

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);
+        } else if (!obj->parent) {
             gchar *name = g_strdup_printf("device[%d]", unattached_count++);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]