From 079eed2e77559582aceece5830b124be1f261922 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 21 Sep 2020 18:10:24 -0400 Subject: [PATCH 01/10] rng-egd: Register "chardev" as class property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated. Signed-off-by: Eduardo Habkost Reviewed-by: Daniel P. Berrangé Message-Id: <20200921221045.699690-4-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- backends/rng-egd.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/backends/rng-egd.c b/backends/rng-egd.c index 20198ff26e..4de142b9dc 100644 --- a/backends/rng-egd.c +++ b/backends/rng-egd.c @@ -135,12 +135,6 @@ static char *rng_egd_get_chardev(Object *obj, Error **errp) return NULL; } -static void rng_egd_init(Object *obj) -{ - object_property_add_str(obj, "chardev", - rng_egd_get_chardev, rng_egd_set_chardev); -} - static void rng_egd_finalize(Object *obj) { RngEgd *s = RNG_EGD(obj); @@ -155,6 +149,8 @@ static void rng_egd_class_init(ObjectClass *klass, void *data) rbc->request_entropy = rng_egd_request_entropy; rbc->opened = rng_egd_opened; + object_class_property_add_str(klass, "chardev", + rng_egd_get_chardev, rng_egd_set_chardev); } static const TypeInfo rng_egd_info = { @@ -162,7 +158,6 @@ static const TypeInfo rng_egd_info = { .parent = TYPE_RNG_BACKEND, .instance_size = sizeof(RngEgd), .class_init = rng_egd_class_init, - .instance_init = rng_egd_init, .instance_finalize = rng_egd_finalize, }; From a3d3ee6c1357749013aa700c929682f41475b158 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 21 Sep 2020 18:10:25 -0400 Subject: [PATCH 02/10] rng-random: register "filename" as class property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated. Signed-off-by: Eduardo Habkost Reviewed-by: Daniel P. Berrangé Message-Id: <20200921221045.699690-5-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- backends/rng-random.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backends/rng-random.c b/backends/rng-random.c index 245b12ab24..7add272edd 100644 --- a/backends/rng-random.c +++ b/backends/rng-random.c @@ -108,10 +108,6 @@ static void rng_random_init(Object *obj) { RngRandom *s = RNG_RANDOM(obj); - object_property_add_str(obj, "filename", - rng_random_get_filename, - rng_random_set_filename); - s->filename = g_strdup("/dev/urandom"); s->fd = -1; } @@ -134,6 +130,10 @@ static void rng_random_class_init(ObjectClass *klass, void *data) rbc->request_entropy = rng_random_request_entropy; rbc->opened = rng_random_opened; + object_class_property_add_str(klass, "filename", + rng_random_get_filename, + rng_random_set_filename); + } static const TypeInfo rng_random_info = { From 29ee2a183205062f8b5b5b317e7fe392e9f57e64 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 21 Sep 2020 18:10:28 -0400 Subject: [PATCH 03/10] rng: Register "opened" as class property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated. Signed-off-by: Eduardo Habkost Reviewed-by: Daniel P. Berrangé Message-Id: <20200921221045.699690-8-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- backends/rng.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backends/rng.c b/backends/rng.c index 484f04e891..3757b04485 100644 --- a/backends/rng.c +++ b/backends/rng.c @@ -105,10 +105,6 @@ static void rng_backend_init(Object *obj) RngBackend *s = RNG_BACKEND(obj); QSIMPLEQ_INIT(&s->requests); - - object_property_add_bool(obj, "opened", - rng_backend_prop_get_opened, - rng_backend_prop_set_opened); } static void rng_backend_finalize(Object *obj) @@ -123,6 +119,10 @@ static void rng_backend_class_init(ObjectClass *oc, void *data) UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); ucc->complete = rng_backend_complete; + + object_class_property_add_bool(oc, "opened", + rng_backend_prop_get_opened, + rng_backend_prop_set_opened); } static const TypeInfo rng_backend_info = { From 7da4e3bb111b4c8fae2ff037f1e1f7934ac8ad50 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 21 Sep 2020 18:10:30 -0400 Subject: [PATCH 04/10] input-linux: Register properties as class properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated. Signed-off-by: Eduardo Habkost Reviewed-by: Daniel P. Berrangé Message-Id: <20200921221045.699690-10-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- ui/input-linux.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/ui/input-linux.c b/ui/input-linux.c index ab351a4187..a339c52cb8 100644 --- a/ui/input-linux.c +++ b/ui/input-linux.c @@ -489,19 +489,6 @@ static void input_linux_set_grab_toggle(Object *obj, int value, static void input_linux_instance_init(Object *obj) { - object_property_add_str(obj, "evdev", - input_linux_get_evdev, - input_linux_set_evdev); - object_property_add_bool(obj, "grab_all", - input_linux_get_grab_all, - input_linux_set_grab_all); - object_property_add_bool(obj, "repeat", - input_linux_get_repeat, - input_linux_set_repeat); - object_property_add_enum(obj, "grab-toggle", "GrabToggleKeys", - &GrabToggleKeys_lookup, - input_linux_get_grab_toggle, - input_linux_set_grab_toggle); } static void input_linux_class_init(ObjectClass *oc, void *data) @@ -509,6 +496,20 @@ static void input_linux_class_init(ObjectClass *oc, void *data) UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); ucc->complete = input_linux_complete; + + object_class_property_add_str(oc, "evdev", + input_linux_get_evdev, + input_linux_set_evdev); + object_class_property_add_bool(oc, "grab_all", + input_linux_get_grab_all, + input_linux_set_grab_all); + object_class_property_add_bool(oc, "repeat", + input_linux_get_repeat, + input_linux_set_repeat); + object_class_property_add_enum(oc, "grab-toggle", "GrabToggleKeys", + &GrabToggleKeys_lookup, + input_linux_get_grab_toggle, + input_linux_set_grab_toggle); } static const TypeInfo input_linux_info = { From d85855b8942d2fdf773e0278facb40855014ff18 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 21 Sep 2020 18:10:31 -0400 Subject: [PATCH 05/10] input-barrier: Register properties as class properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated. Signed-off-by: Eduardo Habkost Reviewed-by: Daniel P. Berrangé Message-Id: <20200921221045.699690-11-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- ui/input-barrier.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/ui/input-barrier.c b/ui/input-barrier.c index a047919fde..81b8d04ec8 100644 --- a/ui/input-barrier.c +++ b/ui/input-barrier.c @@ -689,28 +689,6 @@ static void input_barrier_instance_init(Object *obj) ib->y_origin = 0; ib->width = 1920; ib->height = 1080; - - object_property_add_str(obj, "name", - input_barrier_get_name, - input_barrier_set_name); - object_property_add_str(obj, "server", - input_barrier_get_server, - input_barrier_set_server); - object_property_add_str(obj, "port", - input_barrier_get_port, - input_barrier_set_port); - object_property_add_str(obj, "x-origin", - input_barrier_get_x_origin, - input_barrier_set_x_origin); - object_property_add_str(obj, "y-origin", - input_barrier_get_y_origin, - input_barrier_set_y_origin); - object_property_add_str(obj, "width", - input_barrier_get_width, - input_barrier_set_width); - object_property_add_str(obj, "height", - input_barrier_get_height, - input_barrier_set_height); } static void input_barrier_class_init(ObjectClass *oc, void *data) @@ -718,6 +696,28 @@ static void input_barrier_class_init(ObjectClass *oc, void *data) UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); ucc->complete = input_barrier_complete; + + object_class_property_add_str(oc, "name", + input_barrier_get_name, + input_barrier_set_name); + object_class_property_add_str(oc, "server", + input_barrier_get_server, + input_barrier_set_server); + object_class_property_add_str(oc, "port", + input_barrier_get_port, + input_barrier_set_port); + object_class_property_add_str(oc, "x-origin", + input_barrier_get_x_origin, + input_barrier_set_x_origin); + object_class_property_add_str(oc, "y-origin", + input_barrier_get_y_origin, + input_barrier_set_y_origin); + object_class_property_add_str(oc, "width", + input_barrier_get_width, + input_barrier_set_width); + object_class_property_add_str(oc, "height", + input_barrier_get_height, + input_barrier_set_height); } static const TypeInfo input_barrier_info = { From 3e0dceaf9450ffb65114bd12c62c499c1116f163 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 21 Sep 2020 18:10:34 -0400 Subject: [PATCH 06/10] i386: Register most CPU properties as class properties Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated. Signed-off-by: Eduardo Habkost Reviewed-by: Igor Mammedov Message-Id: <20200921221045.699690-14-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 66 ++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 9eafbe3690..5d713c8528 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6925,44 +6925,12 @@ static void x86_cpu_initfn(Object *obj) env->nr_dies = 1; cpu_set_cpustate_pointers(cpu); - object_property_add(obj, "family", "int", - x86_cpuid_version_get_family, - x86_cpuid_version_set_family, NULL, NULL); - object_property_add(obj, "model", "int", - x86_cpuid_version_get_model, - x86_cpuid_version_set_model, NULL, NULL); - object_property_add(obj, "stepping", "int", - x86_cpuid_version_get_stepping, - x86_cpuid_version_set_stepping, NULL, NULL); - object_property_add_str(obj, "vendor", - x86_cpuid_get_vendor, - x86_cpuid_set_vendor); - object_property_add_str(obj, "model-id", - x86_cpuid_get_model_id, - x86_cpuid_set_model_id); - object_property_add(obj, "tsc-frequency", "int", - x86_cpuid_get_tsc_freq, - x86_cpuid_set_tsc_freq, NULL, NULL); object_property_add(obj, "feature-words", "X86CPUFeatureWordInfo", x86_cpu_get_feature_words, NULL, NULL, (void *)env->features); object_property_add(obj, "filtered-features", "X86CPUFeatureWordInfo", x86_cpu_get_feature_words, NULL, NULL, (void *)cpu->filtered_features); - /* - * The "unavailable-features" property has the same semantics as - * CpuDefinitionInfo.unavailable-features on the "query-cpu-definitions" - * QMP command: they list the features that would have prevented the - * CPU from running if the "enforce" flag was set. - */ - object_property_add(obj, "unavailable-features", "strList", - x86_cpu_get_unavailable_features, - NULL, NULL, NULL); - -#if !defined(CONFIG_USER_ONLY) - object_property_add(obj, "crash-information", "GuestPanicInformation", - x86_cpu_get_crash_info_qom, NULL, NULL, NULL); -#endif for (w = 0; w < FEATURE_WORDS; w++) { int bitnr; @@ -7312,6 +7280,40 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->disas_set_info = x86_disas_set_info; dc->user_creatable = true; + + object_class_property_add(oc, "family", "int", + x86_cpuid_version_get_family, + x86_cpuid_version_set_family, NULL, NULL); + object_class_property_add(oc, "model", "int", + x86_cpuid_version_get_model, + x86_cpuid_version_set_model, NULL, NULL); + object_class_property_add(oc, "stepping", "int", + x86_cpuid_version_get_stepping, + x86_cpuid_version_set_stepping, NULL, NULL); + object_class_property_add_str(oc, "vendor", + x86_cpuid_get_vendor, + x86_cpuid_set_vendor); + object_class_property_add_str(oc, "model-id", + x86_cpuid_get_model_id, + x86_cpuid_set_model_id); + object_class_property_add(oc, "tsc-frequency", "int", + x86_cpuid_get_tsc_freq, + x86_cpuid_set_tsc_freq, NULL, NULL); + /* + * The "unavailable-features" property has the same semantics as + * CpuDefinitionInfo.unavailable-features on the "query-cpu-definitions" + * QMP command: they list the features that would have prevented the + * CPU from running if the "enforce" flag was set. + */ + object_class_property_add(oc, "unavailable-features", "strList", + x86_cpu_get_unavailable_features, + NULL, NULL, NULL); + +#if !defined(CONFIG_USER_ONLY) + object_class_property_add(oc, "crash-information", "GuestPanicInformation", + x86_cpu_get_crash_info_qom, NULL, NULL, NULL); +#endif + } static const TypeInfo x86_cpu_type_info = { From 5949703709e79b779a403d8a5622c1989c86db1c Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 21 Sep 2020 18:10:42 -0400 Subject: [PATCH 07/10] vga-pci: Register "big-endian-framebuffer" as class property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated. Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Message-Id: <20200921221045.699690-22-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/display/vga-pci.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c index e5d9af5868..48d29630ab 100644 --- a/hw/display/vga-pci.c +++ b/hw/display/vga-pci.c @@ -267,13 +267,6 @@ static void pci_std_vga_realize(PCIDevice *dev, Error **errp) } } -static void pci_std_vga_init(Object *obj) -{ - /* Expose framebuffer byteorder via QOM */ - object_property_add_bool(obj, "big-endian-framebuffer", - vga_get_big_endian_fb, vga_set_big_endian_fb); -} - static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp) { PCIVGAState *d = PCI_VGA(dev); @@ -386,6 +379,10 @@ static void vga_class_init(ObjectClass *klass, void *data) k->class_id = PCI_CLASS_DISPLAY_VGA; device_class_set_props(dc, vga_pci_properties); dc->hotpluggable = false; + + /* Expose framebuffer byteorder via QOM */ + object_class_property_add_bool(klass, "big-endian-framebuffer", + vga_get_big_endian_fb, vga_set_big_endian_fb); } static void secondary_class_init(ObjectClass *klass, void *data) @@ -403,7 +400,6 @@ static void secondary_class_init(ObjectClass *klass, void *data) static const TypeInfo vga_info = { .name = "VGA", .parent = TYPE_PCI_VGA, - .instance_init = pci_std_vga_init, .class_init = vga_class_init, }; From abb9369805fe1ebd4eb2d278555c8e06ef099b15 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 21 Sep 2020 18:10:26 -0400 Subject: [PATCH 08/10] vhost-user: Register "chardev" as class property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated. Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Message-Id: <20200921221045.699690-6-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- backends/vhost-user.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backends/vhost-user.c b/backends/vhost-user.c index ae8362d721..b366610e16 100644 --- a/backends/vhost-user.c +++ b/backends/vhost-user.c @@ -175,9 +175,9 @@ static char *get_chardev(Object *obj, Error **errp) return NULL; } -static void vhost_user_backend_init(Object *obj) +static void vhost_user_backend_class_init(ObjectClass *oc, void *data) { - object_property_add_str(obj, "chardev", get_chardev, set_chardev); + object_class_property_add_str(oc, "chardev", get_chardev, set_chardev); } static void vhost_user_backend_finalize(Object *obj) @@ -195,7 +195,7 @@ static const TypeInfo vhost_user_backend_info = { .name = TYPE_VHOST_USER_BACKEND, .parent = TYPE_OBJECT, .instance_size = sizeof(VhostUserBackend), - .instance_init = vhost_user_backend_init, + .class_init = vhost_user_backend_class_init, .instance_finalize = vhost_user_backend_finalize, }; From 14b394853606ab79f1d71f3bbbb4ccaab6538c8f Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Thu, 8 Oct 2020 16:27:11 -0400 Subject: [PATCH 09/10] authz-list-file: Fix crash when filename is not set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the following crash: $ qemu-system-x86_64 -object authz-list-file,id=obj0 qemu-system-x86_64: -object authz-list-file,id=obj0: GLib: g_file_get_contents: assertion 'filename != NULL' failed Segmentation fault (core dumped) Signed-off-by: Eduardo Habkost Reviewed-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Li Qiang Message-Id: <20201008202713.1416823-2-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- authz/listfile.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/authz/listfile.c b/authz/listfile.c index cd6163aa40..aaf930453d 100644 --- a/authz/listfile.c +++ b/authz/listfile.c @@ -122,6 +122,11 @@ qauthz_list_file_complete(UserCreatable *uc, Error **errp) QAuthZListFile *fauthz = QAUTHZ_LIST_FILE(uc); gchar *dir = NULL, *file = NULL; + if (!fauthz->filename) { + error_setg(errp, "filename not provided"); + return; + } + fauthz->list = qauthz_list_file_load(fauthz, errp); if (!fauthz->refresh) { From d9753cca6b0db724bc6d15e60cfad1705f800b96 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Thu, 8 Oct 2020 16:27:12 -0400 Subject: [PATCH 10/10] can-host-socketcan: Fix crash when 'if' option is not set Fix the following crash: $ qemu-system-x86_64 -object can-host-socketcan,id=obj0 Segmentation fault (core dumped) Signed-off-by: Eduardo Habkost Reviewed-by: Li Qiang Acked-by: Pavel Pisa Message-Id: <20201008202713.1416823-3-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- net/can/can_socketcan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/can/can_socketcan.c b/net/can/can_socketcan.c index 92b1f79385..4b68f60c6b 100644 --- a/net/can/can_socketcan.c +++ b/net/can/can_socketcan.c @@ -194,6 +194,11 @@ static void can_host_socketcan_connect(CanHostState *ch, Error **errp) struct sockaddr_can addr; struct ifreq ifr; + if (!c->ifname) { + error_setg(errp, "'if' property not set"); + return; + } + /* open socket */ s = qemu_socket(PF_CAN, SOCK_RAW, CAN_RAW); if (s < 0) {