QOM devices patch queue 2014-03-12
Hello Peter,
This is my QOM (devices) patch queue. Please pull.
Regards,
Andreas
The following changes since commit 750036a848ea913ba6343718ffa70da98f7eef6b:
Merge remote-tracking branch 'remotes/afaerber/tags/prep-for-upstream' into staging (2014-03-12 17:53:37 +0000)
are available in the git repository at:
git://github.com/afaerber/qemu-cpu.git tags/qom-devices-for-peter
for you to fetch changes up to 762384ed3d2503b613d40099bd5dc76600b1c1bd:
libqtest: Fix possible deadlock in qtest initialization (2014-03-12 21:56:20 +0100)
----------------------------------------------------------------
QOM/QTest infrastructure fixes and device conversions
* QTest cleanups and test cases for some virtio devices
* QTest for sPAPR PCI host bridge
* qom-test now tests reading all properties beneath /machine
* QOM API leak fixes
* QOM cleanups for SSI devices
* QOM conversion of QEMUMachine
* QOM realize for buses
* sPAPR PCI bus name change
----------------------------------------------------------------
Alexey Kardashevskiy (2):
spapr-pci: Change the default PCI bus naming
tests: Add spapr-pci-host-bridge qtest
Amos Kong (1):
qdev-monitor: Set properties after parent is assigned in device_add
Andreas Färber (11):
qdev: Fix bus dependency of DeviceState::hotpluggable getter
qom-test: Test QOM properties
tests: Clean up IndustryPack TPCI200 gcov paths
tests: Add virtio-blk qtest
tests: Add virtio-balloon qtest
tests: Add virtio-rng qtest
tests: Add virtio-scsi qtest
tests: Add virtio-serial qtest
tests: Add virtio-console qtest
virtio-console: QOM cast cleanup for VirtConsole
virtio-serial-port: Convert to QOM realize/unrealize
Bandan Das (3):
qdev: Prepare realize/unrealize hooks for BusState
qdev: Realize buses on device realization
pci: Move VMState registration/unregistration to QOM realize/unrealize
Igor Mammedov (1):
qdev: Set DeviceClass::hotpluggable default in class_init()
Marcel Apfelbaum (4):
hw/core: Introduce QEMU machine as QOM object
vl: Use MachineClass instead of global QEMUMachine list hw/boards: Convert current_machine to MachineState
libqtest: Fix possible deadlock in qtest initialization
Markus Armbruster (1):
qdev-monitor-test: Don't test human-readable error message
Peter Crosthwaite (6):
ssi: Convert legacy SSI_SLAVE -> DEVICE casts
ssi: Convert legacy SSI_BUS -> BUS casts misc/max111x: Create abstract max111x type misc/max111x: QOM casting sweep
ssi: Remove SSI_SLAVE_FROM_QDEV() macro block/m25p80: Remove FROM_SSI_SLAVE() usages
Stefan Hajnoczi (2):
qom: Avoid leaking str and bool properties on failure
qdev-monitor-test: Simplify using g_assert_cmpstr()
device-hotplug.c | 4 +- hw/arm/spitz.c | 13 ++-- hw/block/m25p80.c | 9 +-- hw/char/virtio-console.c | 57 ++++++++++-------- hw/char/virtio-serial-bus.c | 51 ++++++++-------- hw/core/Makefile.objs | 2 +- hw/core/machine.c | 28 +++++++++ hw/core/qdev.c | 87 ++++++++++++++++++++++----- hw/display/ads7846.c | 7 ++- hw/display/ssd0323.c | 11 ++-- hw/misc/max111x.c | 54 ++++++++++++----- hw/pci/pci.c | 51 +++++++++------- hw/ppc/spapr_pci.c | 23 +------- hw/sd/ssi-sd.c | 7 ++- hw/ssi/ssi.c | 11 ++-- include/hw/boards.h | 55 ++++++++++++++++- include/hw/qdev-core.h | 6 ++ include/hw/ssi.h | 3 +- include/hw/virtio/virtio-serial.h | 8 +-- qdev-monitor.c | 15 +++-- qmp.c | 7 ++- qom/object.c | 14 ++++- tests/Makefile | 28 ++++++++- tests/libqtest.c | 13 +++- tests/qdev-monitor-test.c | 8 +-- tests/qom-test.c | 43 ++++++++++++++ tests/spapr-phb-test.c | 35 +++++++++++ tests/virtio-balloon-test.c | 33 +++++++++++ tests/virtio-blk-test.c | 34 +++++++++++ tests/virtio-console-test.c | 34 +++++++++++ tests/virtio-rng-test.c | 33 +++++++++++ tests/virtio-scsi-test.c | 35 +++++++++++ tests/virtio-serial-test.c | 33 +++++++++++ vl.c | 121 ++++++++++++++++++++++++++------------ 34 files changed, 757 insertions(+), 216 deletions(-) create mode 100644 hw/core/machine.c create mode 100644 tests/spapr-phb-test.c create mode 100644 tests/virtio-balloon-test.c create mode 100644 tests/virtio-blk-test.c create mode 100644 tests/virtio-console-test.c create mode 100644 tests/virtio-rng-test.c create mode 100644 tests/virtio-scsi-test.c create mode 100644 tests/virtio-serial-test.c
[Qemu-devel] [PULL for-2.0-rc0 01/31] qdev: Fix bus dependency of DeviceState::hotpluggable getter
Commit 1a37eca107cece3ed454bae29eef0bd1fac4a244 (qdev: add "hotpluggable" property to Device) added a property "hotpluggable" to each device, with its getter accessing parent_bus->allow_hotplug.
Add a NULL check.
--- hw/core/qdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/core/qdev.c +2 -1
@@ -735,7 +735,8 @@ static bool device_get_hotpluggable(Object *obj, Error **err)DeviceClass *dc =DEVICE_GET_CLASS (obj);DeviceState *dev =DEVICE (obj); -return dc->hotpluggable && dev->parent_bus->allow_hotplug; +return dc->hotpluggable && (dev->parent_bus ==NULL || + dev->parent_bus->allow_hotplug); }static void device_initfn (Object *obj)
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 02/31] qdev: Set DeviceClass::hotpluggable default in class_init()
In reply to Andreas FärberFrom: Igor Mammedov <[email protected]>
Move setting DeviceClass::hotpluggable default from device's class_base_init() to device's class_init().
--- hw/core/qdev.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
hw/core/qdev.c +8 -8
@@ -793,14 +793,6 @@ static void device_class_base_init(ObjectClass *class, void *data)* so do not propagate them to the subclasses. */ klass->props =NULL ; - -/* by default all devices were considered as hotpluggable, -* so with intent to check it in generic qdev_unplug() / -* device_set_realized() functions make every device -* hotpluggable. Devices that shouldn't be hotpluggable, -* should override it in their class_init() -*/ - klass->hotpluggable = true; }static void device_unparent (Object *obj)
@@ -846,6 +838,14 @@ static void device_class_init(ObjectClass *class, void *data) class->unparent = device_unparent; dc->realize = device_realize; dc->unrealize = device_unrealize; + +/* by default all devices were considered as hotpluggable, +* so with intent to check it in generic qdev_unplug() / +* device_set_realized() functions make every device +* hotpluggable. Devices that shouldn't be hotpluggable, +* should override it in their class_init() +*/ + dc->hotpluggable = true; }void device_reset (DeviceState *dev)
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 04/31] qom: Avoid leaking str and bool properties on failure
In reply to Andreas FärberFrom: Stefan Hajnoczi <[email protected]>
When object_property_add_str() and object_property_add_bool() fail, they leak their internal StringProperty and BoolProperty structs. Remember to free the structs on error.
Luckily this is a low-impact memory leak since most QOM properties are static qdev properties that will never take the error case. object_property_add() only fails if the property name is already in use.
--- qom/object.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
qom/object.c +12 -2
@@ -1293,6 +1293,7 @@ void object_property_add_str(Object *obj, const char *name,void (*set)(Object *,const char *,Error **), Error **errp) { + Error *local_err = NULL;StringProperty *prop =g_malloc0 (sizeof (*prop)); prop->get = get;
@@ -1302,7 +1303,11 @@ void object_property_add_str(Object *obj, const char *name, get ? property_get_str :NULL , set ? property_set_str :NULL , property_release_str, - prop, errp); + prop, &local_err); +if (local_err) { +error_propagate (errp, local_err); +g_free (prop); + } } typedef struct BoolProperty
@@ -1349,6 +1354,7 @@ void object_property_add_bool(Object *obj, const char *name,void (*set)(Object *,bool ,Error **), Error **errp) { + Error *local_err = NULL;BoolProperty *prop =g_malloc0 (sizeof (*prop)); prop->get = get;
@@ -1358,7 +1364,11 @@ void object_property_add_bool(Object *obj, const char *name, get ? property_get_bool :NULL , set ? property_set_bool :NULL , property_release_bool, - prop, errp); + prop, &local_err); +if (local_err) { +error_propagate (errp, local_err); +g_free (prop); + } }static char *qdev_get_type (Object *obj,Error **errp)
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 05/31] ssi: Convert legacy SSI_SLAVE -> DEVICE casts
In reply to Andreas FärberFrom: Peter Crosthwaite <[email protected]>
Convert legacy ->qdev style casts from TYPE_SSI_SLAVE to TYPE_DEVICE.
--- hw/arm/spitz.c | 13 +++++++------ hw/display/ads7846.c | 7 ++++--- hw/display/ssd0323.c | 11 ++++++----- hw/misc/max111x.c | 9 +++++---- hw/sd/ssi-sd.c | 7 ++++--- hw/ssi/ssi.c | 2 +- 6 files changed, 27 insertions(+), 22 deletions(-)
hw/arm/spitz.c +7 -6
@@ -658,14 +658,15 @@ static void spitz_adc_temp_on(void *opaque, int line, int level)max111x_set_input (max1111,MAX1111_BATT_TEMP ,0 ); } -static int corgi_ssp_init (SSISlave *dev) +static int corgi_ssp_init (SSISlave *d) { -CorgiSSPState *s =FROM_SSI_SLAVE (CorgiSSPState, dev); +DeviceState *dev =DEVICE (d); +CorgiSSPState *s =FROM_SSI_SLAVE (CorgiSSPState, d); -qdev_init_gpio_in (&dev->qdev, corgi_ssp_gpio_cs,3 ); - s->bus[0 ] =ssi_create_bus (&dev->qdev,"ssi0" ); - s->bus[1 ] =ssi_create_bus (&dev->qdev,"ssi1" ); - s->bus[2 ] =ssi_create_bus (&dev->qdev,"ssi2" ); +qdev_init_gpio_in (dev, corgi_ssp_gpio_cs,3 ); + s->bus[0 ] =ssi_create_bus (dev,"ssi0" ); + s->bus[1 ] =ssi_create_bus (dev,"ssi1" ); + s->bus[2 ] =ssi_create_bus (dev,"ssi2" );return 0 ; }
hw/display/ads7846.c +4 -3
@@ -133,11 +133,12 @@ static const VMStateDescription vmstate_ads7846 = { } }; -static int ads7846_init (SSISlave *dev) +static int ads7846_init (SSISlave *d) { -ADS7846State *s =FROM_SSI_SLAVE (ADS7846State, dev); +DeviceState *dev =DEVICE (d); +ADS7846State *s =FROM_SSI_SLAVE (ADS7846State, d); -qdev_init_gpio_out (&dev->qdev, &s->interrupt,1 ); +qdev_init_gpio_out (dev, &s->interrupt,1 ); s->input[0 ] =ADS_TEMP0 ;/* TEMP0 */ s->input[2 ] =ADS_VBAT ;/* VBAT */
hw/display/ssd0323.c +6 -5
@@ -336,18 +336,19 @@ static const GraphicHwOps ssd0323_ops = { .gfx_update = ssd0323_update_display, }; -static int ssd0323_init (SSISlave *dev) +static int ssd0323_init (SSISlave *d) { -ssd0323_state *s =FROM_SSI_SLAVE (ssd0323_state, dev); +DeviceState *dev =DEVICE (d); +ssd0323_state *s =FROM_SSI_SLAVE (ssd0323_state, d); s->col_end =63 ; s->row_end =79 ; - s->con =graphic_console_init (DEVICE (dev),0 , &ssd0323_ops, s); + s->con =graphic_console_init (dev,0 , &ssd0323_ops, s);qemu_console_resize (s->con,128 *MAGNIFY ,64 *MAGNIFY ); -qdev_init_gpio_in (&dev->qdev, ssd0323_cd,1 ); +qdev_init_gpio_in (dev, ssd0323_cd,1 ); -register_savevm (&dev->qdev,"ssd0323_oled" ,-1 ,1 , +register_savevm (dev,"ssd0323_oled" ,-1 ,1 , ssd0323_save, ssd0323_load, s);return 0 ; }
hw/misc/max111x.c +5 -4
@@ -115,11 +115,12 @@ static const VMStateDescription vmstate_max111x = { } }; -static int max111x_init (SSISlave *dev,int inputs) +static int max111x_init (SSISlave *d,int inputs) { -MAX111xState *s =FROM_SSI_SLAVE (MAX111xState, dev); +DeviceState *dev =DEVICE (d); +MAX111xState *s =FROM_SSI_SLAVE (MAX111xState, d); -qdev_init_gpio_out (&dev->qdev, &s->interrupt,1 ); +qdev_init_gpio_out (dev, &s->interrupt,1 ); s->inputs = inputs;/* TODO: add a user interface for setting these */
@@ -133,7 +134,7 @@ static int max111x_init(SSISlave *dev, int inputs) s->input[7 ] =0x80 ; s->com =0 ; -vmstate_register (&dev->qdev,-1 , &vmstate_max111x, s); +vmstate_register (dev,-1 , &vmstate_max111x, s);return 0 ; }
hw/sd/ssi-sd.c +4 -3
@@ -238,9 +238,10 @@ static int ssi_sd_load(QEMUFile *f, void *opaque, int version_id)return 0 ; } -static int ssi_sd_init (SSISlave *dev) +static int ssi_sd_init (SSISlave *d) { -ssi_sd_state *s =FROM_SSI_SLAVE (ssi_sd_state, dev); +DeviceState *dev =DEVICE (d); +ssi_sd_state *s =FROM_SSI_SLAVE (ssi_sd_state, d);DriveInfo *dinfo; s->mode =SSI_SD_CMD ;
@@ -249,7 +250,7 @@ static int ssi_sd_init(SSISlave *dev)if (s->sd ==NULL ) {return -1 ; } -register_savevm (&dev->qdev,"ssi_sd" ,-1 ,1 , ssi_sd_save, ssi_sd_load, s); +register_savevm (dev,"ssi_sd" ,-1 ,1 , ssi_sd_save, ssi_sd_load, s);return 0 ; }
hw/ssi/ssi.c +1 -1
@@ -60,7 +60,7 @@ static int ssi_slave_init(DeviceState *dev)if (ssc->transfer_raw == ssi_transfer_raw_default && ssc->cs_polarity !=SSI_CS_NONE ) { -qdev_init_gpio_in (&s->qdev, ssi_cs_default,1 ); +qdev_init_gpio_in (dev, ssi_cs_default,1 ); }return ssc->init (s);
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 07/31] misc/max111x: Create abstract max111x type
In reply to Andreas FärberFrom: Peter Crosthwaite <[email protected]>
Create an abstract class that encompasses both max111x variants. This is needed for QOM cast macro creation (and is the right thing to do anyway). Macroify type-names in the process.
--- hw/misc/max111x.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-)
hw/misc/max111x.c +25 -8
@@ -22,6 +22,11 @@ typedef struct {int inputs, com; } MAX111xState; +#define TYPE_MAX_111X "max111x" + +#define TYPE_MAX_1110 "max1110" +#define TYPE_MAX_1111 "max1111" +/* Control-byte bitfields */ #define CB_PD0 (1 << 0)#define CB_PD1 (1 << 1)
@@ -155,18 +160,31 @@ void max111x_set_input(DeviceState *dev, int line, uint8_t value) s->input[line] = value; } -static void max1110_class_init (ObjectClass *klass,void *data) +static void max111x_class_init (ObjectClass *klass,void *data) {SSISlaveClass *k =SSI_SLAVE_CLASS (klass); - k->init = max1110_init; k->transfer = max111x_transfer; } -static const TypeInfo max1110_info = { - .name ="max1110" , +static const TypeInfo max111x_info = { + .name =TYPE_MAX_111X , .parent =TYPE_SSI_SLAVE , .instance_size =sizeof (MAX111xState), + .class_init = max111x_class_init, + .abstract = true, +}; + +static void max1110_class_init (ObjectClass *klass,void *data) +{ +SSISlaveClass *k =SSI_SLAVE_CLASS (klass); + + k->init = max1110_init; +} + +static const TypeInfo max1110_info = { + .name =TYPE_MAX_1110 , + .parent =TYPE_MAX_111X , .class_init = max1110_class_init, };
@@ -175,18 +193,17 @@ static void max1111_class_init(ObjectClass *klass, void *data)SSISlaveClass *k =SSI_SLAVE_CLASS (klass); k->init = max1111_init; - k->transfer = max111x_transfer; }static const TypeInfo max1111_info = { - .name ="max1111" , - .parent =TYPE_SSI_SLAVE , - .instance_size =sizeof (MAX111xState), + .name =TYPE_MAX_1111 , + .parent =TYPE_MAX_111X , .class_init = max1111_class_init, };static void max111x_register_types (void ) { +type_register_static (&max111x_info);type_register_static (&max1110_info);type_register_static (&max1111_info); }
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 11/31] spapr-pci: Change the default PCI bus naming
In reply to Andreas FärberFrom: Alexey Kardashevskiy <[email protected]>
Previously libvirt required the first/default PCI bus to have name "pci". Since QEMU can support multiple buses now, libvirt wants "pci.0" now.
This removes custom bus name and lets QEMU make up default names.
--- hw/ppc/spapr_pci.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-)
hw/ppc/spapr_pci.c +2 -21
@@ -510,7 +510,6 @@ static int spapr_phb_init(SysBusDevice *s)DeviceState *dev =DEVICE (s);sPAPRPHBState *sphb =SPAPR_PCI_HOST_BRIDGE (s);PCIHostState *phb =PCI_HOST_BRIDGE (s); -const char *busname;char *namebuf;int i;PCIBus *bus;
@@ -594,26 +593,8 @@ static int spapr_phb_init(SysBusDevice *s) get_system_io(), 0, SPAPR_PCI_IO_WIN_SIZE);memory_region_add_subregion (get_system_memory (), sphb->io_win_addr, &sphb->iowindow); -/* -* Selecting a busname is more complex than you'd think, due to -* interacting constraints. If the user has specified an id -* explicitly for the phb , then we want to use the qdev default -* of naming the bus based on the bridge device (so the user can -* then assign devices to it in the way they expect). For the -* first / default PCI bus (index=0) we want to use just "pci" -* because libvirt expects there to be a bus called, simply, -* "pci". Otherwise, we use the same name as in the device tree, -* since it's unique by construction, and makes the guest visible -* BUID clear. -*/ -if (dev->id) { - busname =NULL ; - }else if (sphb->index ==0 ) { - busname ="pci" ; - }else { - busname = sphb->dtbusname; - } - bus =pci_register_bus (dev, busname, + + bus =pci_register_bus (dev,NULL , pci_spapr_set_irq, pci_spapr_map_irq, sphb, &sphb->memspace, &sphb->iospace,PCI_DEVFN (0 ,0 ),PCI_NUM_PINS ,TYPE_PCI_BUS );
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 12/31] qdev-monitor-test: Simplify using g_assert_cmpstr()
In reply to Andreas FärberFrom: Stefan Hajnoczi <[email protected]>
Use g_assert_cmpstr() instead of combining g_assert() and strcmp(3). This simplifies the code since we no longer have to play games to distinguish NULL from "" using "(null)".
gcc extension haters will also be happy that ?: was dropped.
--- tests/qdev-monitor-test.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tests/qdev-monitor-test.c +5 -5
@@ -32,8 +32,9 @@ static void test_device_add(void) "}}");g_assert (response); error =qdict_get_qdict (response,"error" ); -g_assert (!strcmp (qdict_get_try_str (error,"desc" ) ?:"" , -"Device needs media, but drive is empty" )); +g_assert_cmpstr (qdict_get_try_str (error,"desc" ), + ==, +"Device needs media, but drive is empty" );QDECREF (response);/* Delete the drive */
@@ -42,7 +43,7 @@ static void test_device_add(void)" \"command-line\": \"drive_del drive0\"" "}}");g_assert (response); -g_assert (!strcmp (qdict_get_try_str (response,"return" ) ?:"(null)" ,"" )); + g_assert_cmpstr(qdict_get_try_str(response, "return"), ==, "");QDECREF (response);/* Try to re-add the drive. This fails with duplicate IDs if a leaked
@@ -53,8 +54,7 @@ static void test_device_add(void)" \"command-line\": \"drive_add pci-addr=auto if=none,id=drive0\"" "}}");g_assert (response); -g_assert (!strcmp (qdict_get_try_str (response,"return" ) ?:"" , -"OK\r\n" )); + g_assert_cmpstr(qdict_get_try_str(response, "return"), ==, "OK\r\n");QDECREF (response);qtest_end ();
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 13/31] qdev-monitor-test: Don't test human-readable error message
In reply to Andreas FärberFrom: Markus Armbruster <[email protected]>
Test the error class instead. Expecting a specific message is fragile. In fact, it broke once already, in commit 75884af. Restore the test of error member "class" dropped there, and drop the test of error member "desc".
There are no other tests of "desc" as far as I can tell.
--- tests/qdev-monitor-test.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tests/qdev-monitor-test.c +1 -3
@@ -32,9 +32,7 @@ static void test_device_add(void) "}}");g_assert (response); error =qdict_get_qdict (response,"error" ); -g_assert_cmpstr (qdict_get_try_str (error,"desc" ), - ==, -"Device needs media, but drive is empty" ); + g_assert_cmpstr(qdict_get_try_str(error, "class"), ==, "GenericError");QDECREF (response);/* Delete the drive */
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 09/31] ssi: Remove SSI_SLAVE_FROM_QDEV() macro
In reply to Andreas FärberFrom: Peter Crosthwaite <[email protected]>
There are no usages left of this legacy cast. Delete.
ssi: Rename parent field
--- include/hw/ssi.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/hw/ssi.h +1 -2
@@ -56,13 +56,12 @@ typedef struct SSISlaveClass { } SSISlaveClass;struct SSISlave { -DeviceState qdev; +DeviceState parent_obj;/* Chip select state */ bool cs; }; -#define SSI_SLAVE_FROM_QDEV (dev) DO_UPCAST(SSISlave, qdev, dev)#define FROM_SSI_SLAVE (type, dev) DO_UPCAST(type, ssidev, dev)extern const VMStateDescription vmstate_ssi_slave;
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 15/31] vl: Use MachineClass instead of global QEMUMachine list
In reply to Andreas FärberFrom: Marcel Apfelbaum <[email protected]>
The machine registration flow is refactored to use the QOM functionality. Instead of linking the machines into a list, each machine has a type and the types can be traversed in the QOM way.
--- include/hw/boards.h | 1 + vl.c | 75 ++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 55 insertions(+), 21 deletions(-)
include/hw/boards.h +1 -0
@@ -51,6 +51,7 @@ struct QEMUMachine {const char *hw_version; }; +#define TYPE_MACHINE_SUFFIX "-machine"int qemu_register_machine (QEMUMachine *m);QEMUMachine *find_default_machine (void );
vl.c +54 -21
133 lines not on this page · raw message
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 03/31] qdev-monitor: Set properties after parent is assigned in device_add
In reply to Andreas FärberFrom: Amos Kong <[email protected]>
Test steps:
(qemu) device_add e1000,addr=adsf
Property 'e1000.addr' doesn't take value 'adsf'
(qemu) info qtree
Then qemu crashed.
Currently we set a link to the new device from its parent bus, but the device hasn't been added to QOM tree yet. When it fails to set properties, object_unparent() can't clean up the device.
Delay setting of device properties until the device has been added to the QOM composition tree. This way, when setting a property fails, object_unparent() can clean up the device properly.
--- qdev-monitor.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
qdev-monitor.c +9 -6
@@ -522,7 +522,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)return NULL ; } -/* create device, set properties */ +/* create device */ dev =DEVICE (object_new (driver));if (bus) {
@@ -533,11 +533,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)if (id) { dev->id = id; } -if (qemu_opt_foreach (opts, set_property, dev,1 ) !=0 ) { -object_unparent (OBJECT (dev)); -object_unref (OBJECT (dev)); -return NULL ; - } +if (dev->id) {object_property_add_child (qdev_get_peripheral (), dev->id,OBJECT (dev),NULL );
@@ -549,6 +545,13 @@ DeviceState *qdev_device_add(QemuOpts *opts)g_free (name); } +/* set properties */ +if (qemu_opt_foreach (opts, set_property, dev,1 ) !=0 ) { +object_unparent (OBJECT (dev)); +object_unref (OBJECT (dev)); +return NULL ; + } + dev->opts = opts;object_property_set_bool (OBJECT (dev), true,"realized" , &err);if (err !=NULL ) {
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 06/31] ssi: Convert legacy SSI_BUS -> BUS casts
In reply to Andreas FärberFrom: Peter Crosthwaite <[email protected]>
Remove two legacy ->qbus style casts from TYPE_SSI_BUS to TYPE_BUS in ssi.c.
--- hw/ssi/ssi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
hw/ssi/ssi.c +5 -4
@@ -15,7 +15,7 @@#include "hw/ssi.h" struct SSIBus { -BusState qbus; +BusState parent_obj; };#define TYPE_SSI_BUS "SSI"
@@ -88,7 +88,7 @@ static const TypeInfo ssi_slave_info = {DeviceState *ssi_create_slave_no_init (SSIBus *bus,const char *name) { -return qdev_create (&bus->qbus, name); +return qdev_create (BUS (bus), name); }DeviceState *ssi_create_slave (SSIBus *bus,const char *name)
@@ -108,11 +108,12 @@ SSIBus *ssi_create_bus(DeviceState *parent, const char *name)uint32_t ssi_transfer (SSIBus *bus,uint32_t val) { +BusState *b =BUS (bus);BusChild *kid;SSISlaveClass *ssc;uint32_t r =0 ; - QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) { + QTAILQ_FOREACH(kid, &b->children, sibling) {SSISlave *slave =SSI_SLAVE (kid->child); ssc =SSI_SLAVE_GET_CLASS (slave); r |= ssc->transfer_raw (slave, val);
@@ -156,7 +157,7 @@ static int ssi_auto_connect_slave(Object *child, void *opaque) } cs_line =qdev_get_gpio_in (DEVICE (dev),0 ); -qdev_set_parent_bus (DEVICE (dev), &arg->bus->qbus); +qdev_set_parent_bus (DEVICE (dev),BUS (arg->bus)); **arg->cs_linep = cs_line; (*arg->cs_linep)++;return 0 ;
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 08/31] misc/max111x: QOM casting sweep
In reply to Andreas FärberFrom: Peter Crosthwaite <[email protected]>
Define and use QOM cast macro. Removes some usages of legacy casting systems.
--- hw/misc/max111x.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
hw/misc/max111x.c +9 -5
@@ -13,7 +13,8 @@#include "hw/ssi.h" typedef struct { - SSISlave ssidev; + SSISlave parent_obj; + qemu_irq interrupt; uint8_t tb1, rb2, rb3; int cycle;
@@ -24,6 +25,9 @@ typedef struct {#define TYPE_MAX_111X "max111x" +#define MAX_111X (obj) \ + OBJECT_CHECK(MAX111xState, (obj), TYPE_MAX_111X) +#define TYPE_MAX_1110 "max1110"#define TYPE_MAX_1111 "max1111"
@@ -97,7 +101,7 @@ static void max111x_write(MAX111xState *s, uint32_t value)static uint32_t max111x_transfer (SSISlave *dev,uint32_t value) { -MAX111xState *s =FROM_SSI_SLAVE (MAX111xState, dev); +MAX111xState *s =MAX_111X (dev);max111x_write (s, value);return max111x_read (s); }
@@ -108,7 +112,7 @@ static const VMStateDescription vmstate_max111x = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { -VMSTATE_SSI_SLAVE (ssidev, MAX111xState), +VMSTATE_SSI_SLAVE (parent_obj, MAX111xState),VMSTATE_UINT8 (tb1, MAX111xState),VMSTATE_UINT8 (rb2, MAX111xState),VMSTATE_UINT8 (rb3, MAX111xState),
@@ -123,7 +127,7 @@ static const VMStateDescription vmstate_max111x = {static int max111x_init (SSISlave *d,int inputs) {DeviceState *dev =DEVICE (d); -MAX111xState *s =FROM_SSI_SLAVE (MAX111xState, d); +MAX111xState *s =MAX_111X (dev);qdev_init_gpio_out (dev, &s->interrupt,1 );
@@ -155,7 +159,7 @@ static int max1111_init(SSISlave *dev)void max111x_set_input (DeviceState *dev,int line,uint8_t value) { -MAX111xState *s =FROM_SSI_SLAVE (MAX111xState,SSI_SLAVE_FROM_QDEV (dev)); +MAX111xState *s =MAX_111X (dev);assert (line >=0 && line < s->inputs); s->input[line] = value; }
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 10/31] block/m25p80: Remove FROM_SSI_SLAVE() usages
In reply to Andreas FärberFrom: Peter Crosthwaite <[email protected]>
--- hw/block/m25p80.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
hw/block/m25p80.c +5 -4
@@ -241,7 +241,8 @@ typedef enum { } CMDState; typedef struct Flash { - SSISlave ssidev; + SSISlave parent_obj; + uint32_t r; BlockDriverState *bdrv;
@@ -545,7 +546,7 @@ static void decode_new_cmd(Flash *s, uint32_t value)static int m25p80_cs (SSISlave *ss,bool select) { -Flash *s =FROM_SSI_SLAVE (Flash, ss); +Flash *s =M25P80 (ss);if (select) { s->len =0 ;
@@ -561,7 +562,7 @@ static int m25p80_cs(SSISlave *ss, bool select)static uint32_t m25p80_transfer8 (SSISlave *ss,uint32_t tx) { -Flash *s =FROM_SSI_SLAVE (Flash, ss); +Flash *s =M25P80 (ss);uint32_t r =0 ;switch (s->state) {
@@ -610,7 +611,7 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)static int m25p80_init (SSISlave *ss) {DriveInfo *dinfo; -Flash *s =FROM_SSI_SLAVE (Flash, ss); +Flash *s =M25P80 (ss);M25P80Class *mc =M25P80_GET_CLASS (s); s->pi = mc->pi;
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 14/31] hw/core: Introduce QEMU machine as QOM object
In reply to Andreas FärberFrom: Marcel Apfelbaum <[email protected]>
The main functional change is to convert QEMUMachine into MachineClass and QEMUMachineInitArgs into MachineState, instance of MachineClass.
As a first step, in order to make possible an incremental development, both QEMUMachine and QEMUMachineInitArgs are being embedded into the new types.
--- hw/core/Makefile.objs | 2 +- hw/core/machine.c | 28 ++++++++++++++++++++++++++++ include/hw/boards.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 hw/core/machine.c
hw/core/Makefile.objs +1 -1
@@ -8,7 +8,7 @@ common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o common-obj-$(CONFIG_XILINX_AXI) += stream.o common-obj-$(CONFIG_PTIMER) += ptimer.o common-obj-$(CONFIG_SOFTMMU) += sysbus.o +common-obj-$(CONFIG_SOFTMMU) += machine.o common-obj-$(CONFIG_SOFTMMU) += null-machine.o common-obj-$(CONFIG_SOFTMMU) += loader.o common-obj-$(CONFIG_SOFTMMU) += qdev-properties-system.o -
hw/core/machine.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* QEMU Machine +* +* Copyright (C) 2014 Red Hat Inc +* +* Authors: +* Marcel Apfelbaum <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "hw/boards.h" + +static const TypeInfo machine_info = { + .name =TYPE_MACHINE , + .parent =TYPE_OBJECT , + .abstract = true, + .class_size =sizeof (MachineClass), + .instance_size =sizeof (MachineState), +}; + +static void machine_register_types (void ) +{ +type_register_static (&machine_info); +} + +type_init (machine_register_types)
include/hw/boards.h +50 -0
60 lines not on this page · raw message
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 17/31] qom-test: Test QOM properties
In reply to Andreas FärberRecursively walk all properties under /machine and try to retrieve their value. This is a regression test for link<> properties and the DeviceState::hotpluggable property.
Cf. be2f78b6b062eec5170e2612299fb8953046993f and
1a37eca107cece3ed454bae29eef0bd1fac4a244
--- tests/qom-test.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
tests/qom-test.c +43 -0
@@ -10,6 +10,7 @@#include <glib.h> #include <string.h> +#include "qemu-common.h" #include "libqtest.h" #include "qemu/osdep.h" #include "qapi/qmp/types.h"
@@ -43,6 +44,44 @@ static bool is_blacklisted(const char *arch, const char *mach)return false; } +static void test_properties (const char *path) +{ +char *cmd, *child_path; +QDict *response, *tuple; +QList *list; +QListEntry *entry; + +g_test_message ("Obtaining properties of %s" , path); + cmd =g_strdup_printf ("{ 'execute': 'qom-list'," +" 'arguments': { 'path': '%s' } }" , path); + response =qmp (cmd); +g_free (cmd); +g_assert (response); + +g_assert (qdict_haskey (response,"return" )); + list =qobject_to_qlist (qdict_get (response,"return" )); + QLIST_FOREACH_ENTRY(list, entry) { + tuple =qobject_to_qdict (qlist_entry_obj (entry)); +if (strstart (qdict_get_str (tuple,"type" ),"child<" ,NULL )) { + child_path =g_strdup_printf ("%s/%s" , + path,qdict_get_str (tuple,"name" )); +test_properties (child_path); +g_free (child_path); + }else { +const char *prop =qdict_get_str (tuple,"name" ); +g_test_message ("Testing property %s.%s" , path, prop); + cmd =g_strdup_printf ("{ 'execute': 'qom-get'," +" 'arguments': { 'path': '%s'," +" 'property': '%s' } }" , + path, prop); + response =qmp (cmd); +g_free (cmd); +/* qom-get may fail but should not, e.g., segfault. */ +g_assert (response); + } + } +} +static void test_machine (gconstpointer data) {const char *machine = data;
@@ -51,8 +90,12 @@ static void test_machine(gconstpointer data) args =g_strdup_printf ("-machine %s" , machine);qtest_start (args); + +test_properties ("/machine" ); + response =qmp ("{ 'execute': 'quit' }" );g_assert (qdict_haskey (response,"return" )); +qtest_end ();g_free (args); }
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 19/31] tests: Add virtio-blk qtest
In reply to Andreas Färber--- tests/Makefile | 3 +++ tests/virtio-blk-test.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/virtio-blk-test.c
tests/Makefile +3 -0
@@ -72,6 +72,8 @@ gcov-files-ipack-y += hw/char/ipoctal232.c gcov-files-virtio-y += i386-softmmu/hw/virtio/virtio.c check-qtest-virtio-y += tests/virtio-net-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/net/virtio-net.c +check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF) +gcov-files-virtio-y += i386-softmmu/hw/block/virtio-blk.c check-qtest-pci-y += tests/e1000-test$(EXESUF) gcov-files-pci-y += hw/net/e1000.c
@@ -239,6 +241,7 @@ tests/pcnet-test$(EXESUF): tests/pcnet-test.o tests/eepro100-test$(EXESUF): tests/eepro100-test.o tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o tests/ne2000-test$(EXESUF): tests/ne2000-test.o +tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o tests/tpci200-test$(EXESUF): tests/tpci200-test.o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o
tests/virtio-blk-test.c new file +34 -0
@@ -0,0 +1,34 @@ +/* +* QTest testcase for VirtIO Block Device +* +* Copyright (c) 2014 SUSE LINUX Products GmbH +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop (void ) +{ +} + +int main (int argc,char **argv) +{ +int ret; + +g_test_init (&argc, &argv,NULL ); +qtest_add_func ("/virtio/blk/pci/nop" , pci_nop); + +qtest_start ("-drive id=drv0,if=none,file=/dev/null " +"-device virtio-blk-pci,drive=drv0" ); + ret =g_test_run (); + +qtest_end (); + +return ret; +}
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 20/31] tests: Add virtio-balloon qtest
In reply to Andreas Färber--- tests/Makefile | 3 +++ tests/virtio-balloon-test.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/virtio-balloon-test.c
tests/Makefile +3 -0
@@ -72,6 +72,8 @@ gcov-files-ipack-y += hw/char/ipoctal232.c gcov-files-virtio-y += i386-softmmu/hw/virtio/virtio.c check-qtest-virtio-y += tests/virtio-net-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/net/virtio-net.c +check-qtest-virtio-y += tests/virtio-balloon-test$(EXESUF) +gcov-files-virtio-y += i386-softmmu/hw/virtio/virtio-balloon.c check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/block/virtio-blk.c
@@ -241,6 +243,7 @@ tests/pcnet-test$(EXESUF): tests/pcnet-test.o tests/eepro100-test$(EXESUF): tests/eepro100-test.o tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o tests/ne2000-test$(EXESUF): tests/ne2000-test.o +tests/virtio-balloon-test$(EXESUF): tests/virtio-balloon-test.o tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o tests/tpci200-test$(EXESUF): tests/tpci200-test.o
tests/virtio-balloon-test.c new file +33 -0
@@ -0,0 +1,33 @@ +/* +* QTest testcase for VirtIO Balloon +* +* Copyright (c) 2014 SUSE LINUX Products GmbH +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop (void ) +{ +} + +int main (int argc,char **argv) +{ +int ret; + +g_test_init (&argc, &argv,NULL ); +qtest_add_func ("/virtio/balloon/pci/nop" , pci_nop); + +qtest_start ("-device virtio-balloon-pci" ); + ret =g_test_run (); + +qtest_end (); + +return ret; +}
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 18/31] tests: Clean up IndustryPack TPCI200 gcov paths
In reply to Andreas Färber--- tests/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tests/Makefile +2 -2
@@ -87,9 +87,9 @@ gcov-files-pci-y += hw/net/ne2000.c check-qtest-pci-y += $(check-qtest-virtio-y) gcov-files-pci-y += $(gcov-files-virtio-y) hw/virtio/virtio-pci.c check-qtest-pci-y += tests/tpci200-test$(EXESUF) -gcov-files-pci-y += hw/char/tpci200.c +gcov-files-pci-y += hw/ipack/tpci200.c check-qtest-pci-y += $(check-qtest-ipack-y) -gcov-files-pci-y += $(gcov-files-ipack-y) hw/ipack/tpci200.c +gcov-files-pci-y += $(gcov-files-ipack-y) check-qtest-i386-y = tests/endianness-test$(EXESUF) check-qtest-i386-y += tests/fdc-test$(EXESUF)
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 21/31] tests: Add virtio-rng qtest
In reply to Andreas Färber--- tests/Makefile | 3 +++ tests/virtio-rng-test.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/virtio-rng-test.c
tests/Makefile +3 -0
@@ -76,6 +76,8 @@ check-qtest-virtio-y += tests/virtio-balloon-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/virtio/virtio-balloon.c check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/block/virtio-blk.c +check-qtest-virtio-y += tests/virtio-rng-test$(EXESUF) +gcov-files-virtio-y += hw/virtio/virtio-rng.c check-qtest-pci-y += tests/e1000-test$(EXESUF) gcov-files-pci-y += hw/net/e1000.c
@@ -246,6 +248,7 @@ tests/ne2000-test$(EXESUF): tests/ne2000-test.o tests/virtio-balloon-test$(EXESUF): tests/virtio-balloon-test.o tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o +tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o tests/tpci200-test$(EXESUF): tests/tpci200-test.o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o tests/qom-test$(EXESUF): tests/qom-test.o
tests/virtio-rng-test.c new file +33 -0
@@ -0,0 +1,33 @@ +/* +* QTest testcase for VirtIO RNG +* +* Copyright (c) 2014 SUSE LINUX Products GmbH +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop (void ) +{ +} + +int main (int argc,char **argv) +{ +int ret; + +g_test_init (&argc, &argv,NULL ); +qtest_add_func ("/virtio/rng/pci/nop" , pci_nop); + +qtest_start ("-device virtio-rng-pci" ); + ret =g_test_run (); + +qtest_end (); + +return ret; +}
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 23/31] tests: Add virtio-serial qtest
In reply to Andreas Färber--- tests/Makefile | 3 +++ tests/virtio-serial-test.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/virtio-serial-test.c
tests/Makefile +3 -0
@@ -80,6 +80,8 @@ check-qtest-virtio-y += tests/virtio-rng-test$(EXESUF) gcov-files-virtio-y += hw/virtio/virtio-rng.c check-qtest-virtio-y += tests/virtio-scsi-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/scsi/virtio-scsi.c +check-qtest-virtio-y += tests/virtio-serial-test$(EXESUF) +gcov-files-virtio-y += i386-softmmu/hw/char/virtio-serial-bus.c check-qtest-pci-y += tests/e1000-test$(EXESUF) gcov-files-pci-y += hw/net/e1000.c
@@ -252,6 +254,7 @@ tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o tests/virtio-scsi-test$(EXESUF): tests/virtio-scsi-test.o +tests/virtio-serial-test$(EXESUF): tests/virtio-serial-test.o tests/tpci200-test$(EXESUF): tests/tpci200-test.o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o tests/qom-test$(EXESUF): tests/qom-test.o
tests/virtio-serial-test.c new file +33 -0
@@ -0,0 +1,33 @@ +/* +* QTest testcase for VirtIO Serial +* +* Copyright (c) 2014 SUSE LINUX Products GmbH +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop (void ) +{ +} + +int main (int argc,char **argv) +{ +int ret; + +g_test_init (&argc, &argv,NULL ); +qtest_add_func ("/virtio/serial/pci/nop" , pci_nop); + +qtest_start ("-device virtio-serial-pci" ); + ret =g_test_run (); + +qtest_end (); + +return ret; +}
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 27/31] tests: Add spapr-pci-host-bridge qtest
In reply to Andreas FärberFrom: Alexey Kardashevskiy <[email protected]>
This adds a test whether sPAPR PHB can be added via the command line.
--- tests/Makefile | 3 +++ tests/spapr-phb-test.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/spapr-phb-test.c
tests/Makefile +3 -0
@@ -144,6 +144,8 @@ check-qtest-arm-y = tests/tmp105-test$(EXESUF) gcov-files-arm-y += hw/misc/tmp105.c check-qtest-ppc-y += tests/boot-order-test$(EXESUF) check-qtest-ppc64-y += tests/boot-order-test$(EXESUF) +check-qtest-ppc64-y += tests/spapr-phb-test$(EXESUF) +gcov-files-ppc64-y += ppc64-softmmu/hw/ppc/spapr_pci.c check-qtest-microblazeel-y = $(check-qtest-microblaze-y) check-qtest-xtensaeb-y = $(check-qtest-xtensa-y)
@@ -240,6 +242,7 @@ libqos-omap-obj-y = $(libqos-obj-y) tests/libqos/i2c-omap.o tests/rtc-test$(EXESUF): tests/rtc-test.o tests/m48t59-test$(EXESUF): tests/m48t59-test.o tests/endianness-test$(EXESUF): tests/endianness-test.o +tests/spapr-phb-test$(EXESUF): tests/spapr-phb-test.o $(libqos-obj-y) tests/fdc-test$(EXESUF): tests/fdc-test.o tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y) tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o
tests/spapr-phb-test.c new file +35 -0
@@ -0,0 +1,35 @@ +/* +* QTest testcase for SPAPR PHB +* +* Authors: +* Alexey Kardashevskiy <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ +#include <glib.h> + +#include "libqtest.h" + +#define TYPE_SPAPR_PCI_HOST_BRIDGE "spapr-pci-host-bridge" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void test_phb_device (void ) +{ +} + +int main (int argc,char **argv) +{ +int ret; + +g_test_init (&argc, &argv,NULL ); +qtest_add_func ("/spapr-phb/device" , test_phb_device); + +qtest_start ("-device " TYPE_SPAPR_PCI_HOST_BRIDGE ",index=100" ); + + ret =g_test_run (); + +qtest_end (); + +return ret; +}
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 16/31] hw/boards: Convert current_machine to MachineState
In reply to Andreas FärberFrom: Marcel Apfelbaum <[email protected]>
In order to allow attaching machine options to a machine instance, current_machine is converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return MachineClass.
--- device-hotplug.c | 4 ++- include/hw/boards.h | 6 ++--- qmp.c | 7 ++++-- vl.c | 72 +++++++++++++++++++++++++++++++---------------------- 4 files changed, 53 insertions(+), 36 deletions(-)
device-hotplug.c +3 -1
@@ -33,12 +33,14 @@ DriveInfo *add_init_drive(const char *optstr) {DriveInfo *dinfo;QemuOpts *opts; +MachineClass *mc; opts =drive_def (optstr);if (!opts)return NULL ; - dinfo =drive_init (opts, current_machine->block_default_type); + mc =MACHINE_GET_CLASS (current_machine); + dinfo =drive_init (opts, mc->qemu_machine->block_default_type);if (!dinfo) {qemu_opts_del (opts);return NULL ;
include/hw/boards.h +3 -3
@@ -53,9 +53,6 @@ struct QEMUMachine {#define TYPE_MACHINE_SUFFIX "-machine"int qemu_register_machine (QEMUMachine *m); -QEMUMachine *find_default_machine (void ); - -extern QEMUMachine *current_machine;#define TYPE_MACHINE "machine"#define MACHINE (obj) \
@@ -68,6 +65,9 @@ extern QEMUMachine *current_machine;typedef struct MachineState MachineState ;typedef struct MachineClass MachineClass ; +MachineClass *find_default_machine (void ); +extern MachineState *current_machine; +/** * MachineClass: * @qemu_machine: #QEMUMachine
qmp.c +5 -2
@@ -114,8 +114,11 @@ void qmp_cpu(int64_t index, Error **errp)void qmp_cpu_add (int64_t id,Error **errp) { -if (current_machine->hot_add_cpu) { - current_machine->hot_add_cpu (id, errp); +MachineClass *mc; + + mc =MACHINE_GET_CLASS (current_machine); +if (mc->qemu_machine->hot_add_cpu) { + mc->qemu_machine->hot_add_cpu (id, errp); }else {error_setg (errp,"Not supported" ); }
vl.c +42 -30
175 lines not on this page · raw message
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 24/31] tests: Add virtio-console qtest
In reply to Andreas Färber--- tests/Makefile | 6 ++++++ tests/virtio-console-test.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/virtio-console-test.c
tests/Makefile +6 -0
@@ -69,6 +69,9 @@ gcov-files-ipack-y += hw/ipack/ipack.c check-qtest-ipack-y += tests/ipoctal232-test$(EXESUF) gcov-files-ipack-y += hw/char/ipoctal232.c +check-qtest-virtioserial-y += tests/virtio-console-test$(EXESUF) +gcov-files-virtioserial-y += hw/char/virtio-console.c + gcov-files-virtio-y += i386-softmmu/hw/virtio/virtio.c check-qtest-virtio-y += tests/virtio-net-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/net/virtio-net.c
@@ -82,6 +85,8 @@ check-qtest-virtio-y += tests/virtio-scsi-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/scsi/virtio-scsi.c check-qtest-virtio-y += tests/virtio-serial-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/char/virtio-serial-bus.c +check-qtest-virtio-y += $(check-qtest-virtioserial-y) +gcov-files-virtio-y += $(gcov-files-virtioserial-y) check-qtest-pci-y += tests/e1000-test$(EXESUF) gcov-files-pci-y += hw/net/e1000.c
@@ -255,6 +260,7 @@ tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o tests/virtio-scsi-test$(EXESUF): tests/virtio-scsi-test.o tests/virtio-serial-test$(EXESUF): tests/virtio-serial-test.o +tests/virtio-console-test$(EXESUF): tests/virtio-console-test.o tests/tpci200-test$(EXESUF): tests/tpci200-test.o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o tests/qom-test$(EXESUF): tests/qom-test.o
tests/virtio-console-test.c new file +34 -0
@@ -0,0 +1,34 @@ +/* +* QTest testcase for VirtIO Console +* +* Copyright (c) 2014 SUSE LINUX Products GmbH +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop (void ) +{ +} + +int main (int argc,char **argv) +{ +int ret; + +g_test_init (&argc, &argv,NULL ); +qtest_add_func ("/virtio/console/pci/nop" , pci_nop); + +qtest_start ("-device virtio-serial-pci,id=vser0 " +"-device virtconsole,bus=vser0.0" ); + ret =g_test_run (); + +qtest_end (); + +return ret; +}
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 25/31] virtio-console: QOM cast cleanup for VirtConsole
In reply to Andreas FärberIntroduce type constant, cast macro and rename parent field.
--- hw/char/virtio-console.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
hw/char/virtio-console.c +20 -13
@@ -15,8 +15,13 @@#include "trace.h" #include "hw/virtio/virtio-serial.h" +#define TYPE_VIRTIO_CONSOLE "virtconsole" +#define VIRTIO_CONSOLE (obj) \ + OBJECT_CHECK(VirtConsole, (obj), TYPE_VIRTIO_CONSOLE) +typedef struct VirtConsole { -VirtIOSerialPort port; +VirtIOSerialPort parent_obj; +CharDriverState *chr;guint watch; }VirtConsole ;
@@ -31,7 +36,7 @@ static gboolean chr_write_unblocked(GIOChannel *chan, GIOCondition cond,VirtConsole *vcon = opaque; vcon->watch =0 ; -virtio_serial_throttle_port (&vcon->port, false); +virtio_serial_throttle_port (VIRTIO_SERIAL_PORT (vcon), false);return FALSE; }
@@ -39,7 +44,7 @@ static gboolean chr_write_unblocked(GIOChannel *chan, GIOCondition cond,static ssize_t flush_buf (VirtIOSerialPort *port,const uint8_t *buf,ssize_t len) { -VirtConsole *vcon =DO_UPCAST (VirtConsole, port, port); +VirtConsole *vcon =VIRTIO_CONSOLE (port);ssize_t ret;if (!vcon->chr) {
@@ -75,7 +80,7 @@ static ssize_t flush_buf(VirtIOSerialPort *port,/* Callback function that's called when the guest opens/closes the port */ static void set_guest_connected (VirtIOSerialPort *port,int guest_connected) { -VirtConsole *vcon =DO_UPCAST (VirtConsole, port, port); +VirtConsole *vcon =VIRTIO_CONSOLE (port);if (!vcon->chr) {return ;
@@ -88,40 +93,42 @@ static int chr_can_read(void *opaque) {VirtConsole *vcon = opaque; -return virtio_serial_guest_ready (&vcon->port); +return virtio_serial_guest_ready (VIRTIO_SERIAL_PORT (vcon)); }/* Send data from a char device over to the guest */ static void chr_read (void *opaque,const uint8_t *buf,int size) {VirtConsole *vcon = opaque; +VirtIOSerialPort *port =VIRTIO_SERIAL_PORT (vcon); -trace_virtio_console_chr_read (vcon->port.id, size); -virtio_serial_write (&vcon->port, buf, size); +trace_virtio_console_chr_read (port->id, size); +virtio_serial_write (port, buf, size); }static void chr_event (void *opaque,int event) {VirtConsole *vcon = opaque; +VirtIOSerialPort *port =VIRTIO_SERIAL_PORT (vcon); -trace_virtio_console_chr_event (vcon->port.id, event); +trace_virtio_console_chr_event (port->id, event);switch (event) {case CHR_EVENT_OPENED : -virtio_serial_open (&vcon->port); +virtio_serial_open (port);break ;case CHR_EVENT_CLOSED :if (vcon->watch) {g_source_remove (vcon->watch); vcon->watch =0 ; } -virtio_serial_close (&vcon->port); +virtio_serial_close (port);break ; } }static int virtconsole_initfn (VirtIOSerialPort *port) { -VirtConsole *vcon =DO_UPCAST (VirtConsole, port, port); +VirtConsole *vcon =VIRTIO_CONSOLE (port);VirtIOSerialPortClass *k =VIRTIO_SERIAL_PORT_GET_CLASS (port);if (port->id ==0 && !k->is_console) {
@@ -140,7 +147,7 @@ static int virtconsole_initfn(VirtIOSerialPort *port)static int virtconsole_exitfn (VirtIOSerialPort *port) { -VirtConsole *vcon =DO_UPCAST (VirtConsole, port, port); +VirtConsole *vcon =VIRTIO_CONSOLE (port);if (vcon->watch) {g_source_remove (vcon->watch);
@@ -168,7 +175,7 @@ static void virtconsole_class_init(ObjectClass *klass, void *data) }static const TypeInfo virtconsole_info = { - .name ="virtconsole" , + .name =TYPE_VIRTIO_CONSOLE , .parent =TYPE_VIRTIO_SERIAL_PORT , .instance_size =sizeof (VirtConsole), .class_init = virtconsole_class_init,
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 22/31] tests: Add virtio-scsi qtest
In reply to Andreas Färber--- tests/Makefile | 3 +++ tests/virtio-scsi-test.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/virtio-scsi-test.c
tests/Makefile +3 -0
@@ -78,6 +78,8 @@ check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/block/virtio-blk.c check-qtest-virtio-y += tests/virtio-rng-test$(EXESUF) gcov-files-virtio-y += hw/virtio/virtio-rng.c +check-qtest-virtio-y += tests/virtio-scsi-test$(EXESUF) +gcov-files-virtio-y += i386-softmmu/hw/scsi/virtio-scsi.c check-qtest-pci-y += tests/e1000-test$(EXESUF) gcov-files-pci-y += hw/net/e1000.c
@@ -249,6 +251,7 @@ tests/virtio-balloon-test$(EXESUF): tests/virtio-balloon-test.o tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o +tests/virtio-scsi-test$(EXESUF): tests/virtio-scsi-test.o tests/tpci200-test$(EXESUF): tests/tpci200-test.o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o tests/qom-test$(EXESUF): tests/qom-test.o
tests/virtio-scsi-test.c new file +35 -0
@@ -0,0 +1,35 @@ +/* +* QTest testcase for VirtIO SCSI +* +* Copyright (c) 2014 SUSE LINUX Products GmbH +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include <glib.h> +#include <string.h> +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop (void ) +{ +} + +int main (int argc,char **argv) +{ +int ret; + +g_test_init (&argc, &argv,NULL ); +qtest_add_func ("/virtio/scsi/pci/nop" , pci_nop); + +qtest_start ("-drive id=drv0,if=none,file=/dev/null " +"-device virtio-scsi-pci,id=vscsi0 " +"-device scsi-hd,bus=vscsi0.0,drive=drv0" ); + ret =g_test_run (); + +qtest_end (); + +return ret; +}
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 26/31] virtio-serial-port: Convert to QOM realize/unrealize
In reply to Andreas Färber--- hw/char/virtio-console.c | 28 ++++++++++----------- hw/char/virtio-serial-bus.c | 51 ++++++++++++++++++++------------------- include/hw/virtio/virtio-serial.h | 8 +++--- 3 files changed, 43 insertions(+), 44 deletions(-)
hw/char/virtio-console.c +13 -15
@@ -126,14 +126,16 @@ static void chr_event(void *opaque, int event) } } -static int virtconsole_initfn (VirtIOSerialPort *port) +static void virtconsole_realize (DeviceState *dev,Error **errp) { -VirtConsole *vcon =VIRTIO_CONSOLE (port); -VirtIOSerialPortClass *k =VIRTIO_SERIAL_PORT_GET_CLASS (port); +VirtIOSerialPort *port =VIRTIO_SERIAL_PORT (dev); +VirtConsole *vcon =VIRTIO_CONSOLE (dev); +VirtIOSerialPortClass *k =VIRTIO_SERIAL_PORT_GET_CLASS (dev);if (port->id ==0 && !k->is_console) { -error_report ("Port number 0 on virtio-serial devices reserved for virtconsole devices for backward compatibility." ); -return -1 ; +error_setg (errp,"Port number 0 on virtio-serial devices reserved " +"for virtconsole devices for backward compatibility." ); +return ; }if (vcon->chr) {
@@ -141,19 +143,15 @@ static int virtconsole_initfn(VirtIOSerialPort *port)qemu_chr_add_handlers (vcon->chr, chr_can_read, chr_read, chr_event, vcon); } - -return 0 ; } -static int virtconsole_exitfn (VirtIOSerialPort *port) +static void virtconsole_unrealize (DeviceState *dev,Error **errp) { -VirtConsole *vcon =VIRTIO_CONSOLE (port); +VirtConsole *vcon =VIRTIO_CONSOLE (dev);if (vcon->watch) {g_source_remove (vcon->watch); } - -return 0 ; }static Property virtconsole_properties[] = {
@@ -167,8 +165,8 @@ static void virtconsole_class_init(ObjectClass *klass, void *data)VirtIOSerialPortClass *k =VIRTIO_SERIAL_PORT_CLASS (klass); k->is_console = true; - k->init = virtconsole_initfn; - k->exit = virtconsole_exitfn; + k->realize = virtconsole_realize; + k->unrealize = virtconsole_unrealize; k->have_data = flush_buf; k->set_guest_connected = set_guest_connected; dc->props = virtconsole_properties;
@@ -191,8 +189,8 @@ static void virtserialport_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);VirtIOSerialPortClass *k =VIRTIO_SERIAL_PORT_CLASS (klass); - k->init = virtconsole_initfn; - k->exit = virtconsole_exitfn; + k->realize = virtconsole_realize; + k->unrealize = virtconsole_unrealize; k->have_data = flush_buf; k->set_guest_connected = set_guest_connected; dc->props = virtserialport_properties;
hw/char/virtio-serial-bus.c +26 -25
104 lines not on this page · raw message
include/hw/virtio/virtio-serial.h +4 -4
@@ -81,15 +81,15 @@ typedef struct VirtIOSerialPortClass {bool is_console;/* -* The per-port (or per-app) init function that's called when a +* The per-port (or per-app) realize function that's called when a * new device is found on the bus. */ -int (*init)(VirtIOSerialPort *port); +DeviceRealize realize;/* -* Per-port exit function that's called when a port gets +* Per-port unrealize function that's called when a port gets * hot-unplugged or removed. */ -int (*exit)(VirtIOSerialPort *port); +DeviceUnrealize unrealize;/* Callbacks for guest events */ /* Guest opened/closed device. */
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 29/31] qdev: Realize buses on device realization
In reply to Andreas FärberFrom: Bandan Das <[email protected]>
Integrate (un)realization of child buses with realization/unrealization of the device hosting them. Code in device_unparent() is reordered for unrealization of buses to work as part of device unrealization.
That way no changes need to be made to bus instantiation.
--- hw/core/qdev.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-)
hw/core/qdev.c +22 -5
@@ -716,6 +716,7 @@ static void device_set_realized(Object *obj, bool value, Error **err) {DeviceState *dev =DEVICE (obj);DeviceClass *dc =DEVICE_GET_CLASS (dev); +BusState *bus;Error *local_err =NULL ;if (dev->hotplugged && !dc->hotpluggable) {
@@ -749,14 +750,30 @@ static void device_set_realized(Object *obj, bool value, Error **err) dev->instance_id_alias, dev->alias_required_for_version); } +if (local_err ==NULL ) { + QLIST_FOREACH(bus, &dev->child_bus, sibling) { +object_property_set_bool (OBJECT (bus), true,"realized" , + &local_err); +if (local_err !=NULL ) { +break ; + } + } + }if (dev->hotplugged && local_err ==NULL ) {device_reset (dev); } }else if (!value && dev->realized) { -if (qdev_get_vmsd (dev)) { + QLIST_FOREACH(bus, &dev->child_bus, sibling) { +object_property_set_bool (OBJECT (bus), false,"realized" , + &local_err); +if (local_err !=NULL ) { +break ; + } + } +if (qdev_get_vmsd (dev) && local_err ==NULL ) {vmstate_unregister (dev,qdev_get_vmsd (dev), dev); } -if (dc->unrealize) { +if (dc->unrealize && local_err ==NULL ) { dc->unrealize (dev, &local_err); } }
@@ -841,13 +858,13 @@ static void device_unparent(Object *obj)QObject *event_data;bool have_realized = dev->realized; +if (dev->realized) { +object_property_set_bool (obj, false,"realized" ,NULL ); + }while (dev->num_child_bus) { bus =QLIST_FIRST (&dev->child_bus);object_unparent (OBJECT (bus)); } -if (dev->realized) { -object_property_set_bool (obj, false,"realized" ,NULL ); - }if (dev->parent_bus) {bus_remove_child (dev->parent_bus, dev);object_unref (OBJECT (dev->parent_bus));
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 31/31] libqtest: Fix possible deadlock in qtest initialization
In reply to Andreas FärberFrom: Marcel Apfelbaum <[email protected]>
'socket_accept' waits for QEMU to init its unix socket. If QEMU encounters an error during command line parsing, it can exit before initializing the communication channel.
Using a timeout for sockets fixes the issue.
--- tests/libqtest.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
tests/libqtest.c +11 -2
@@ -34,6 +34,7 @@#include "qapi/qmp/json-parser.h" #define MAX_IRQ 256 +#define SOCKET_TIMEOUT 5QTestState *global_qtest;
@@ -78,12 +79,16 @@ static int socket_accept(int sock)struct sockaddr_un addr;socklen_t addrlen;int ret; +struct timeval timeout = { .tv_sec =SOCKET_TIMEOUT , + .tv_usec =0 }; + +setsockopt (sock,SOL_SOCKET ,SO_RCVTIMEO , (void *)&timeout, +sizeof (timeout)); addrlen =sizeof (addr);do { ret =accept (sock, (struct sockaddr *)&addr, &addrlen); }while (ret ==-1 && errno ==EINTR ); -g_assert_no_errno (ret);close (sock);return ret;
@@ -147,12 +152,16 @@ QTestState *qtest_init(const char *extra_args) } s->fd =socket_accept (sock); - s->qmp_fd =socket_accept (qmpsock); +if (s->fd >=0 ) { + s->qmp_fd =socket_accept (qmpsock); + }unlink (socket_path);unlink (qmp_socket_path);g_free (socket_path);g_free (qmp_socket_path); +g_assert (s->fd >=0 && s->qmp_fd >=0 ); + s->rx =g_string_new ("" );for (i =0 ; i <MAX_IRQ ; i++) { s->irq_level[i] = false;
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 28/31] qdev: Prepare realize/unrealize hooks for BusState
In reply to Andreas FärberFrom: Bandan Das <[email protected]>
Add a "realized" property calling realize/unrealize hooks as for devices.
--- hw/core/qdev.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/hw/qdev-core.h | 6 ++++++ 2 files changed, 47 insertions(+)
hw/core/qdev.c +41 -0
@@ -501,6 +501,45 @@ static void bus_unparent(Object *obj) } } +static bool bus_get_realized (Object *obj,Error **err) +{ +BusState *bus =BUS (obj); + +return bus->realized; +} + +static void bus_set_realized (Object *obj,bool value,Error **err) +{ +BusState *bus =BUS (obj); +BusClass *bc =BUS_GET_CLASS (bus); +Error *local_err =NULL ; + +if (value && !bus->realized) { +if (bc->realize) { + bc->realize (bus, &local_err); + +if (local_err !=NULL ) { + goto error; + } + + } + }else if (!value && bus->realized) { +if (bc->unrealize) { + bc->unrealize (bus, &local_err); + +if (local_err !=NULL ) { + goto error; + } + } + } + + bus->realized = value; +return ; + +error: +error_propagate (err, local_err); +} +void qbus_create_inplace (void *bus,size_t size,const char *typename,DeviceState *parent,const char *name) {
@@ -889,6 +928,8 @@ static void qbus_initfn(Object *obj)object_property_add_link (obj,QDEV_HOTPLUG_HANDLER_PROPERTY ,TYPE_HOTPLUG_HANDLER , (Object **)&bus->hotplug_handler,NULL ); +object_property_add_bool (obj,"realized" , + bus_get_realized, bus_set_realized,NULL ); }static char *default_bus_get_fw_dev_path (DeviceState *dev)
include/hw/qdev-core.h +6 -0
@@ -36,6 +36,8 @@ typedef int (*qdev_event)(DeviceState *dev);typedef void (*qdev_resetfn )(DeviceState *dev);typedef void (*DeviceRealize )(DeviceState *dev,Error **errp);typedef void (*DeviceUnrealize )(DeviceState *dev,Error **errp); +typedef void (*BusRealize )(BusState *bus,Error **errp); +typedef void (*BusUnrealize )(BusState *bus,Error **errp);struct VMStateDescription ;
@@ -174,6 +176,9 @@ struct BusClass {*/ char *(*get_fw_dev_path)(DeviceState *dev);void (*reset)(BusState *bus); +BusRealize realize; +BusUnrealize unrealize; +/* maximum devices allowed on the bus, 0: no limit. */ int max_dev;/* number of automatically allocated bus ids (e.g. ide.0) */
@@ -199,6 +204,7 @@ struct BusState {int allow_hotplug;HotplugHandler *hotplug_handler;int max_index; +bool realized; QTAILQ_HEAD(ChildrenHead, BusChild) children;QLIST_ENTRY (BusState) sibling; };
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL for-2.0-rc0 30/31] pci: Move VMState registration/unregistration to QOM realize/unrealize
In reply to Andreas FärberFrom: Bandan Das <[email protected]>
Use the realize and unrealize hooks to register and unregister vmstate_pcibus respectively.
Relocate some stuff to avoid forward declarations.
--- hw/pci/pci.c | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-)
hw/pci/pci.c +30 -21
@@ -48,7 +48,6 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent);static char *pcibus_get_dev_path (DeviceState *dev);static char *pcibus_get_fw_dev_path (DeviceState *dev);static void pcibus_reset (BusState *qbus); -static void pci_bus_finalize (Object *obj);static Property pci_props[] = {DEFINE_PROP_PCI_DEVFN ("addr" , PCIDevice, devfn,-1 ),
@@ -61,6 +60,34 @@ static Property pci_props[] = {DEFINE_PROP_END_OF_LIST () }; +static const VMStateDescription vmstate_pcibus = { + .name ="PCIBUS" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_INT32_EQUAL (nirq, PCIBus), +VMSTATE_VARRAY_INT32 (irq_count, PCIBus, + nirq,0 , vmstate_info_int32, + int32_t), +VMSTATE_END_OF_LIST () + } +}; + +static void pci_bus_realize (BusState *qbus,Error **errp) +{ +PCIBus *bus =PCI_BUS (qbus); + +vmstate_register (NULL ,-1 , &vmstate_pcibus, bus); +} + +static void pci_bus_unrealize (BusState *qbus,Error **errp) +{ +PCIBus *bus =PCI_BUS (qbus); + +vmstate_unregister (NULL , &vmstate_pcibus, bus); +} +static void pci_bus_class_init (ObjectClass *klass,void *data) {BusClass *k =BUS_CLASS (klass);
@@ -68,6 +95,8 @@ static void pci_bus_class_init(ObjectClass *klass, void *data) k->print_dev = pcibus_dev_print; k->get_dev_path = pcibus_get_dev_path; k->get_fw_dev_path = pcibus_get_fw_dev_path; + k->realize = pci_bus_realize; + k->unrealize = pci_bus_unrealize; k->reset = pcibus_reset; }
@@ -75,7 +104,6 @@ static const TypeInfo pci_bus_info = { .name = TYPE_PCI_BUS, .parent = TYPE_BUS, .instance_size = sizeof(PCIBus), - .instance_finalize = pci_bus_finalize, .class_init = pci_bus_class_init, };
@@ -95,17 +123,6 @@ static uint16_t pci_default_sub_device_id = PCI_SUBDEVICE_ID_QEMU; static QLIST_HEAD(, PCIHostState) pci_host_bridges; -static const VMStateDescription vmstate_pcibus = { - .name ="PCIBUS" , - .version_id =1 , - .minimum_version_id =1 , - .minimum_version_id_old =1 , - .fields = (VMStateField []) { -VMSTATE_INT32_EQUAL (nirq, PCIBus), -VMSTATE_VARRAY_INT32 (irq_count, PCIBus, nirq,0 , vmstate_info_int32, int32_t), -VMSTATE_END_OF_LIST () - } -};static int pci_bar (PCIDevice *d,int reg) {uint8_t type;
@@ -299,8 +316,6 @@ static void pci_bus_init(PCIBus *bus, DeviceState *parent,QLIST_INIT (&bus->child);pci_host_bus_register (bus, parent); - -vmstate_register (NULL ,-1 , &vmstate_pcibus, bus); }bool pci_bus_is_express (PCIBus *bus)
@@ -369,12 +384,6 @@ int pci_bus_num(PCIBus *s)return s->parent_dev->config[PCI_SECONDARY_BUS ]; } -static void pci_bus_finalize (Object *obj) -{ -PCIBus *bus =PCI_BUS (obj); -vmstate_unregister (NULL , &vmstate_pcibus, bus); -} -static int get_pci_config_device (QEMUFile *f,void *pv,size_t size) {PCIDevice *s =container_of (pv, PCIDevice, config);
Signature · 1 line
1.8.4.5
Quoted 3 lines · Andreas Färber
Hello Peter,
This is my QOM (devices) patch queue. Please pull.
Hi. I'm afraid this fails make check:
CC tests/qom-test.o/home/petmay01/linaro/qemu-for-merges/tests/qom-test.c: In function ‘qmp’:/home/petmay01/linaro/qemu-for-merges/tests/libqtest.h:359:60: sorry,
unimplemented: function ‘qmp’ can never be inlined because it uses variable argument lists
make: *** [tests/qom-test.o] Error 1
Non-debug build, gcc-4.6.real (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, x86-64.
thanks
-- PMM
Am 12.03.2014 23:42, schrieb Peter Maydell:
Quoted 13 lines · Andreas Färber
Quoted 3 lines
Hello Peter,
This is my QOM (devices) patch queue. Please pull.
Hi. I'm afraid this fails make check:
CCtests/qom-test.o/home/petmay01/linaro/qemu-for-merges/tests/qom-test.c: In function ‘qmp’:/home/petmay01/linaro/qemu-for-merges/tests/libqtest.h:359:60: sorry,
unimplemented: function ‘qmp’ can never be inlined because it uses variable argument lists
make: *** [tests/qom-test.o] Error 1
Quoted 2 lines
Non-debug build, gcc-4.6.real (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, x86-64.
Can't reproduce with 4.8.1, whether with --enable-debug or without, but comparing other qmp() uses I noticed that I can simplify my code as follows:
tests/qom-test.c +0 -0
@@ -46,16 +46,14 @@ static bool is_blacklisted(const char *arch, const
char *mac
h)
static void test_properties(const char *path)
{
- char *cmd, *child_path;
+ char *child_path;
QDict *response, *tuple;
QList *list;
QListEntry *entry;
g_test_message("Obtaining properties of %s", path);
- cmd = g_strdup_printf("{ 'execute': 'qom-list',"
- " 'arguments': { 'path': '%s' } }", path);
- response = qmp(cmd);
- g_free(cmd);
+ response = qmp("{ 'execute': 'qom-list',"
+ " 'arguments': { 'path': '%s' } }", path);
g_assert(response);
g_assert(qdict_haskey(response, "return"));
@@ -70,12 +68,10 @@ static void test_properties(const char *path)
} else {
const char *prop = qdict_get_str(tuple, "name");
g_test_message("Testing property %s.%s", path, prop);
- cmd = g_strdup_printf("{ 'execute': 'qom-get',"
- " 'arguments': { 'path': '%s',"
- " 'property': '%s' } }",
- path, prop);
- response = qmp(cmd);
- g_free(cmd);
+ response = qmp("{ 'execute': 'qom-get',"
+ " 'arguments': { 'path': '%s',"
+ " 'property': '%s' } }",
+ path, prop);
/* qom-get may fail but should not, e.g., segfault. */
g_assert(response);
}Maybe that helps...
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
[Qemu-devel] virtio-serial broken in qemu.git (was: Re: [PULL for-2.0-rc0 25/31] virtio-console: QOM cast cleanup for VirtConsole)
In reply to Andreas Färbergit bisect is unsure, but one of these commits seems to have completely broken virtio-serial.
There are only 'skip'ped commits left to test.
The first bad commit could be any of:
0399a3819b27083ba69b88a9baa9025facab85bd
2ef66625f3a8978dcbbad773e6813f747971381e
We cannot bisect more!
Anyhow, the error is:
hw/char/virtio-console.c:132:virtconsole_realize: Object 0x7f85482fb8a0 is not an instance of type virtconsole
The full log including command line is attached.
Rich.
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
************************************************************
* IMPORTANT NOTICE
*
* When reporting bugs, include the COMPLETE, UNEDITED
* output below in your bug report.
*
************************************************************LIBGUESTFS_HV=/home/rjones/d/qemu/x86_64-softmmu/qemu-system-x86_64 PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/rjones/.local/bin:/home/rjones/bin
SELinux: Enforcingguestfs_get_append: (null)guestfs_get_autosync: 1guestfs_get_backend: libvirtguestfs_get_backend_settings: []guestfs_get_cachedir: /var/tmpguestfs_get_direct: 0guestfs_get_hv: /home/rjones/d/qemu/x86_64-softmmu/qemu-system-x86_64guestfs_get_memsize: 500guestfs_get_network: 0guestfs_get_path: /usr/lib64/guestfsguestfs_get_pgroup: 0guestfs_get_program: libguestfs-test-toolguestfs_get_recovery_proc: 1guestfs_get_selinux: 0guestfs_get_smp: 1guestfs_get_tmpdir: /tmpguestfs_get_trace: 0guestfs_get_verbose: 1host_cpu: x86_64
Launching appliance, timeout set to 600 seconds.
libguestfs: launch: program=libguestfs-test-tool
libguestfs: launch: version=1.25.44fedora=21,release=1.fc21,libvirt
libguestfs: launch: backend registered: unix
libguestfs: launch: backend registered: uml
libguestfs: launch: backend registered: libvirt
libguestfs: launch: backend registered: direct
libguestfs: launch: backend=libvirt
libguestfs: launch: tmpdir=/tmp/libguestfsKgILEw
libguestfs: launch: umask=0002
libguestfs: launch: euid=1000
libguestfs: libvirt version = 1001003 (1.1.3)
libguestfs: guest random name = guestfs-194p50rg5rpq1l6z
libguestfs: [00000ms] connect to libvirt
libguestfs: opening libvirt handle: URI = qemu:///session, auth = default+wrapper, flags = 0
libguestfs: successfully opened libvirt handle: conn = 0x7f780fc31f50
libguestfs: qemu version (reported by libvirt) = 1007000 (1.7.0)
libguestfs: [01629ms] get libvirt capabilities
libguestfs: [01633ms] parsing capabilities XML
libguestfs: [01634ms] build appliance
libguestfs: [01634ms] begin building supermin appliance
libguestfs: [01634ms] run supermin
libguestfs: command: run: /usr/bin/supermin
libguestfs: command: run: \ --build
libguestfs: command: run: \ --verbose
libguestfs: command: run: \ --if-newer
libguestfs: command: run: \ --lock /var/tmp/.guestfs-1000/lock
libguestfs: command: run: \ --copy-kernel
libguestfs: command: run: \ -f ext2
libguestfs: command: run: \ --host-cpu x86_64
libguestfs: command: run: \ /usr/lib64/guestfs/supermin.d
libguestfs: command: run: \ -o /var/tmp/.guestfs-1000/appliance.d
supermin: version: 5.1.4
supermin: package handler: fedora/rpm
supermin: acquiring lock on /var/tmp/.guestfs-1000/lock
supermin: if-newer: output does not need rebuilding
libguestfs: [01639ms] finished building supermin appliance
libguestfs: command: run: qemu-img
libguestfs: command: run: \ create
libguestfs: command: run: \ -f qcow2
libguestfs: command: run: \ -o backing_file=/var/tmp/.guestfs-1000/appliance.d/root,backing_fmt=raw
libguestfs: command: run: \ /tmp/libguestfsKgILEw/overlay2
Formatting '/tmp/libguestfsKgILEw/overlay2', fmt=qcow2 size=4294967296 backing_file='/var/tmp/.guestfs-1000/appliance.d/root' backing_fmt='raw' encryption=off cluster_size=65536 lazy_refcounts=off
libguestfs: [02148ms] create libvirt XML
libguestfs: libvirt XML:\n<?xml version="1.0"?>\n<domain type="kvm" xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0">\n <name>guestfs-194p50rg5rpq1l6z</name>\n <memory unit="MiB">500</memory>\n <currentMemory unit="MiB">500</currentMemory>\n <cpu mode="host-passthrough">\n <model fallback="allow"/>\n </cpu>\n <vcpu>1</vcpu>\n <clock offset="utc">\n <timer name="rtc" tickpolicy="catchup"/>\n <timer name="pit" tickpolicy="delay"/>\n <timer name="hpet" present="no"/>\n </clock>\n <os>\n <type>hvm</type>\n <kernel>/var/tmp/.guestfs-1000/appliance.d/kernel</kernel>\n <initrd>/var/tmp/.guestfs-1000/appliance.d/initrd</initrd>\n <cmdline>panic=1 console=ttyS0 udevtimeout=600 no_timer_check acpi=off printk.time=1 cgroup_disable=memory root=/dev/sdb selinux=0 guestfs_verbose=1 TERM=xterm-256color</cmdline>\n </os>\n <seclabel type="none"/>\n <on_reboot>destroy</on_reboot>\n <devices>\n <emulator>/home/rjones/d/qemu/x86_64-softmmu/qemu-system-x86_64</emulator>\n <controller type="scsi" index="0" model="virtio-scsi"/>\n <disk device="disk" type="file">\n <source file="/tmp/libguestfsKgILEw/scratch.1"/>\n <target dev="sda" bus="scsi"/>\n <driver name="qemu" type="raw" cache="unsafe"/>\n <address type="drive" controller="0" bus="0" target="0" unit="0"/>\n </disk>\n <disk type="file" device="disk">\n <source file="/tmp/libguestfsKgILEw/overlay2"/>\n <target dev="sdb" bus="scsi"/>\n <driver name="qemu" type="qcow2" cache="unsafe"/>\n <address type="drive" controller="0" bus="0" target="1" unit="0"/>\n <shareable/>\n </disk>\n <serial type="unix">\n <source mode="connect" path="/tmp/libguestfsKgILEw/console.sock"/>\n <target port="0"/>\n </serial>\n <channel type="unix">\n <source mode="connect" path="/tmp/libguestfsKgILEw/guestfsd.sock"/>\n <target type="virtio" name="org.libguestfs.channel.0"/>\n </channel>\n </devices>\n <qemu:commandline>\n <qemu:env name="TMPDIR" value="/var/tmp"/>\n </qemu:commandline>\n</domain>\n
libguestfs: command: run: ls
libguestfs: command: run: \ -a
libguestfs: command: run: \ -l
libguestfs: command: run: \ -Z /var/tmp/.guestfs-1000
libguestfs: drwxr-xr-x. rjones rjones unconfined_u:object_r:user_tmp_t:s0 .
libguestfs: drwxrwxrwt. root root system_u:object_r:tmp_t:s0 ..
libguestfs: drwxr-xr-x. rjones rjones unconfined_u:object_r:user_tmp_t:s0 appliance.d
libguestfs: -rwxr-xr-x. rjones rjones unconfined_u:object_r:user_tmp_t:s0 checksum
libguestfs: -rw-r--r--. rjones rjones system_u:object_r:virt_content_t:s0 initrd
libguestfs: -rw-r--r--. rjones rjones system_u:object_r:virt_content_t:s0 initrd.4942
libguestfs: -rw-r--r--. rjones rjones system_u:object_r:virt_content_t:s0 kernel
libguestfs: -rw-r--r--. rjones rjones system_u:object_r:virt_content_t:s0 kernel.4942
libguestfs: -rw-r--r--. rjones rjones unconfined_u:object_r:user_tmp_t:s0 lock
libguestfs: -rw-r--r--. rjones rjones system_u:object_r:virt_content_t:s0 root
libguestfs: -rw-r--r--. rjones rjones system_u:object_r:virt_content_t:s0 root.4942
libguestfs: command: run: ls
libguestfs: command: run: \ -a
libguestfs: command: run: \ -l
libguestfs: command: run: \ -Z /tmp/libguestfsKgILEw
libguestfs: drwxr-xr-x. rjones rjones unconfined_u:object_r:user_tmp_t:s0 .
libguestfs: drwxrwxrwt. root root system_u:object_r:tmp_t:s0 ..
libguestfs: srwxrwxr-x. rjones rjones unconfined_u:object_r:user_tmp_t:s0 console.sock
libguestfs: srwxrwxr-x. rjones rjones unconfined_u:object_r:user_tmp_t:s0 guestfsd.sock
libguestfs: -rw-r--r--. rjones rjones unconfined_u:object_r:user_tmp_t:s0 overlay2
libguestfs: -rw-rw-r--. rjones rjones unconfined_u:object_r:user_tmp_t:s0 scratch.1
libguestfs: -rwxrwxr-x. rjones rjones unconfined_u:object_r:user_tmp_t:s0 umask-check
libguestfs: [02154ms] launch libvirt guest
libguestfs: error: could not create appliance through libvirt.
Try running qemu directly without libvirt using this environment variable:
export LIBGUESTFS_BACKEND=direct
Original error from libvirt: internal error: process exited while connecting to monitor: hw/char/virtio-console.c:132:virtconsole_realize: Object 0x7f85482fb8a0 is not an instance of type virtconsole
[code=1 domain=10]
libguestfs-test-tool: failed to launch appliance
libguestfs: closing guestfs handle 0x7f780fc31840 (state 0)
libguestfs: command: run: rm
libguestfs: command: run: \ -rf /tmp/libguestfsKgILEw
Re: [Qemu-devel] virtio-serial broken in qemu.git (was: Re: [PULL for-2.0-rc0 25/31] virtio-console: QOM cast cleanup for VirtConsole)
Quoted 5 lines · Richard W.M. Jones
Anyhow, the error is:
hw/char/virtio-console.c:132:virtconsole_realize: Object
0x7f85482fb8a0is not an instance of type virtconsoleThe full log including command line is attached.
Sorry, I realize that libvirt hid the command line. The command line and log was:
2014-03-13 15:31:25.718+0000: starting up
LC_ALL=C PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/rjones/.local/bin:/home/rjones/bin HOME=/home/rjones USER=rjones LOGNAME=rjones QEMU_AUDIO_DRV=none TMPDIR=/var/tmp /home/rjones/d/qemu/x86_64-softmmu/qemu-system-x86_64 -name guestfs-194p50rg5rpq1l6z -S -machine pc-i440fx-2.0,accel=kvm,usb=off -cpu host -m 500 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 54abc82b-46c8-4c8c-9152-97272a1d8325 -nographic -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/home/rjones/.config/libvirt/qemu/lib/guestfs-194p50rg5rpq1l6z.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-hpet -no-reboot -no-acpi -kernel /var/tmp/.guestfs-1000/appliance.d/kernel -initrd /var/tmp/.guestfs-1000/appliance.d/initrd -append panic=1 console=ttyS0 udevtimeout=600 no_timer_check acpi=off printk.time=1 cgroup_disable=memory root=/dev/sdb selinux=0 guestfs_verbose=1 TERM=xterm-256color -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x2 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 -drive file=/tmp/libguestfsKgILEw/scratch.1,if=none,id=drive-scsi0-0-0-0,format=raw,cache=unsafe -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 -drive file=/tmp/libguestfsKgILEw/overlay2,if=none,id=drive-scsi0-0-1-0,format=qcow2,cache=unsafe -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=1,lun=0,drive=drive-scsi0-0-1-0,id=scsi0-0-1-0 -chardev socket,id=charserial0,path=/tmp/libguestfsKgILEw/console.sock -device isa-serial,chardev=charserial0,id=serial0 -chardev socket,id=charchannel0,path=/tmp/libguestfsKgILEw/guestfsd.sock -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.libguestfs.channel.0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 Domain id=2 is tainted: custom-argv
Domain id=2 is tainted: host-cpu
hw/char/virtio-console.c:132:virtconsole_realize: Object 0x7f85482fb8a0 is not an instance of type virtconsole
2014-03-13 15:31:25.922+0000: shutting down
Rich.
Signature · 3 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#)