Skip to contentSkip to conversation

qom: Fix regression with 'qom-type'

PATCH In review Eric Blake 5 participants 5 messages Mar 23, 2017

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

PATCH 1/1 qom: Fix regression with 'qom-type'

Commit 9a6d1ac assumed that 'qom-type' could be removed from QemuOpts with no ill effects. However, this command line proves otherwise:

$ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -nographic -qmp stdio \
  -object rng-random,filename=/dev/urandom,id=rng0 \
  -device virtio-rng-pci,rng=rng0
qemu-system-x86_64: -object rng-random,filename=/dev/urandom,id=rng0: Parameter 'qom-type' is missing

Fix the regression by restoring qom-type in opts after its temporary removal that was needed for the duration of user_creatable_add_opts().

---
 qom/object_interfaces.c | 2 ++
 1 file changed, 2 insertions(+)
qom/object_interfaces.c +2 -0
index 9c271ad..d4253a8 100644
@@ -122,6 +122,7 @@ Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
     }
     if (!id) {
         error_setg(errp, QERR_MISSING_PARAMETER, "id");
+        qemu_opt_set(opts, "qom-type", type, &error_abort);
         g_free(type);
         return NULL;
     }
@@ -134,6 +135,7 @@ Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
     visit_free(v);
 
     qemu_opts_set_id(opts, (char *) id);
+    qemu_opt_set(opts, "qom-type", type, &error_abort);
     g_free(type);
     QDECREF(pdict);
     return obj;
Signature · 1 line
2.9.3
Tested-by on v1 1/1
#1 lore raw
Quoted 30 lines · Eric Blake

Commit 9a6d1ac assumed that 'qom-type' could be removed from QemuOpts with no ill effects. However, this command line proves otherwise:

$ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -nographic -qmp stdio \
  -object rng-random,filename=/dev/urandom,id=rng0 \
  -device virtio-rng-pci,rng=rng0
qemu-system-x86_64: -object rng-random,filename=/dev/urandom,id=rng0: Parameter 'qom-type' is missing

Fix the regression by restoring qom-type in opts after its temporary removal that was needed for the duration of user_creatable_add_opts().

---
 qom/object_interfaces.c | 2 ++
 1 file changed, 2 insertions(+)
qom/object_interfaces.c +1 -0
index 9c271ad..d4253a8 100644
@@ -122,6 +122,7 @@ Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
     }
     if (!id) {
         error_setg(errp, QERR_MISSING_PARAMETER, "id");
+        qemu_opt_set(opts, "qom-type", type, &error_abort);
         g_free(type);
         return NULL;
     }

qom/object_interfaces.c Object *user_creatable_add_opts(QemuOpts *opts, Error **errp) · line 141

Quoted 7 lines
qom/object_interfaces.c +1 -0
@@ -134,6 +135,7 @@ Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
     visit_free(v);
 
     qemu_opts_set_id(opts, (char *) id);
+    qemu_opt_set(opts, "qom-type", type, &error_abort);
     g_free(type);
     QDECREF(pdict);
     return obj;

Thanks Eric. Yes, this fixes the problem I observed before with libguestfs.

Rich.

Signature · 5 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
Reviewed-by on v1 1/1
#2 lore raw
In reply to Eric Blake
Quoted 7 lines · Eric Blake

Commit 9a6d1ac assumed that 'qom-type' could be removed from QemuOpts with no ill effects. However, this command line proves otherwise:

$ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -nographic -qmp stdio \
  -object rng-random,filename=/dev/urandom,id=rng0 \
  -device virtio-rng-pci,rng=rng0
qemu-system-x86_64: -object rng-random,filename=/dev/urandom,id=rng0: Parameter 'qom-type' is missing

Shows that our test coverage is still inadequate. Also shows that I should do more manual testing myself. Sorry for the inconvenience!

Quoted 22 lines

Fix the regression by restoring qom-type in opts after its temporary removal that was needed for the duration of user_creatable_add_opts().

---
 qom/object_interfaces.c | 2 ++
 1 file changed, 2 insertions(+)
qom/object_interfaces.c +1 -0
index 9c271ad..d4253a8 100644
@@ -122,6 +122,7 @@ Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
     }
     if (!id) {
         error_setg(errp, QERR_MISSING_PARAMETER, "id");
+        qemu_opt_set(opts, "qom-type", type, &error_abort);
         g_free(type);
         return NULL;
     }

qom/object_interfaces.c Object *user_creatable_add_opts(QemuOpts *opts, Error **errp) · line 141

Quoted 7 lines
qom/object_interfaces.c +1 -0
@@ -134,6 +135,7 @@ Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
     visit_free(v);
 
     qemu_opts_set_id(opts, (char *) id);
+    qemu_opt_set(opts, "qom-type", type, &error_abort);
     g_free(type);
     QDECREF(pdict);
     return obj;

The awkwardness increases a bit more, but I don't have better ideas.

Peter, can you apply this as a build fix?

#3 lore raw
Quoted 45 lines · Markus Armbruster
Quoted 7 lines · Eric Blake

Commit 9a6d1ac assumed that 'qom-type' could be removed from QemuOpts with no ill effects. However, this command line proves otherwise:

$ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -nographic -qmp stdio \
  -object rng-random,filename=/dev/urandom,id=rng0 \
  -device virtio-rng-pci,rng=rng0
qemu-system-x86_64: -object rng-random,filename=/dev/urandom,id=rng0: Parameter 'qom-type' is missing

Shows that our test coverage is still inadequate. Also shows that I should do more manual testing myself. Sorry for the inconvenience!

Quoted 22 lines

Fix the regression by restoring qom-type in opts after its temporary removal that was needed for the duration of user_creatable_add_opts().

---
 qom/object_interfaces.c | 2 ++
 1 file changed, 2 insertions(+)
qom/object_interfaces.c +1 -0
index 9c271ad..d4253a8 100644
@@ -122,6 +122,7 @@ Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
     }
     if (!id) {
         error_setg(errp, QERR_MISSING_PARAMETER, "id");
+        qemu_opt_set(opts, "qom-type", type, &error_abort);
         g_free(type);
         return NULL;
     }

qom/object_interfaces.c Object *user_creatable_add_opts(QemuOpts *opts, Error **errp) · line 141

Quoted 7 lines
qom/object_interfaces.c +1 -0
@@ -134,6 +135,7 @@ Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
     visit_free(v);
 
     qemu_opts_set_id(opts, (char *) id);
+    qemu_opt_set(opts, "qom-type", type, &error_abort);
     g_free(type);
     QDECREF(pdict);
     return obj;

The awkwardness increases a bit more, but I don't have better ideas.

Quoted 3 lines

Peter, can you apply this as a build fix?

Sure; applied to master.

-- PMM

Tested-by on v1 1/1
#4 lore raw
In reply to Eric Blake
Quoted 31 lines · Eric Blake

Commit 9a6d1ac assumed that 'qom-type' could be removed from QemuOpts with no ill effects. However, this command line proves otherwise:

$ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -nographic -qmp stdio \
  -object rng-random,filename=/dev/urandom,id=rng0 \
  -device virtio-rng-pci,rng=rng0
qemu-system-x86_64: -object rng-random,filename=/dev/urandom,id=rng0: Parameter 'qom-type' is missing

Fix the regression by restoring qom-type in opts after its temporary removal that was needed for the duration of user_creatable_add_opts().

---
 qom/object_interfaces.c | 2 ++
 1 file changed, 2 insertions(+)
qom/object_interfaces.c +1 -0
index 9c271ad..d4253a8 100644
@@ -122,6 +122,7 @@ Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
     }
     if (!id) {
         error_setg(errp, QERR_MISSING_PARAMETER, "id");
+        qemu_opt_set(opts, "qom-type", type, &error_abort);
         g_free(type);
         return NULL;
     }

qom/object_interfaces.c Object *user_creatable_add_opts(QemuOpts *opts, Error **errp) · line 141

Quoted 7 lines
qom/object_interfaces.c +1 -0
@@ -134,6 +135,7 @@ Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
     visit_free(v);
 
     qemu_opts_set_id(opts, (char *) id);
+    qemu_opt_set(opts, "qom-type", type, &error_abort);
     g_free(type);
     QDECREF(pdict);
     return obj;