Skip to contentSkip to conversation

qdev: rework device properties.

RFC PATCH Superseded Gerd Hoffmann 3 participants 6 messages Jun 30, 2009 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 qdev: rework device properties.

Early RfC patch. Not functional yet. Just for comments right now.

Overall plan:
* drop property lists. The properties are saved directly in the device state structs instead.
* drop qdev_get_prop* functions, not needed any more.
* replace qdev_set_prop* functions by qdev_prop_{parse,set*}.

Done:
* added code to handle properties.

Todo:
* convert all the device drivers.
* actually drop the old functions.

---
 Makefile             |    2 +-
 hw/qdev-properties.c |  166 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/qdev.c            |   80 ++----------------------
 hw/qdev.h            |   44 +++++++++-----
 hw/syborg_timer.c    |   10 ++-
 5 files changed, 208 insertions(+), 94 deletions(-)
 create mode 100644 hw/qdev-properties.c
Makefile +1 -1
index 918e927..af5b190 100644
@@ -108,7 +108,7 @@ obj-y += bt-hci-csr.o
 obj-y += buffered_file.o migration.o migration-tcp.o net.o qemu-sockets.o
 obj-y += qemu-char.o aio.o net-checksum.o savevm.o cache-utils.o
 obj-y += msmouse.o ps2.o
-obj-y += qdev.o ssi.o
+obj-y += qdev.o qdev-properties.o ssi.o
 
 obj-$(CONFIG_BRLAPI) += baum.o
 
hw/qdev-properties.c new file +166 -0

166 lines not on this page · raw message

hw/qdev.c +5 -75

142 lines not on this page · raw message

hw/qdev.h +29 -15

84 lines not on this page · raw message

hw/syborg_timer.c +7 -3
index 4f5e3a1..f3d00d8 100644
@@ -230,9 +230,13 @@ static SysBusDeviceInfo syborg_timer_info = {
     .init = syborg_timer_init,
     .qdev.name  = "syborg,timer",
     .qdev.size  = sizeof(SyborgTimerState),
-    .qdev.props = (DevicePropList[]) {
-        {.name = "frequency", .type = PROP_TYPE_INT},
-        {.name = NULL}
+    .qdev.props = (Property[]) {
+        {
+            .name   = "frequency",
+            .info   = &qdev_prop_uint32,
+            .offset = offsetof(SyborgTimerState, freq),
+        },
+        {/* end of list */}
     }
 };
 
Signature · 1 line
1.6.2.5
#1 lore raw
Quoted 8 lines · Gerd Hoffmann

Early RfC patch. Not functional yet. Just for comments right now.

Overall plan:
* drop property lists. The properties are saved directly in the device state structs instead.
* drop qdev_get_prop* functions, not needed any more.
* replace qdev_set_prop* functions by qdev_prop_{parse,set*}.

Quoted 6 lines

Done:
* added code to handle properties.

Todo:
* convert all the device drivers.
* actually drop the old functions.

Any good reason why you remove the list of propierties?

What I want to do, to make usb modular I need two things:

a- a way to defino an alias, that "mouse" is equivalent to "QEMU USB
Keyboard". One is the qdev name and the other is the name passed to --usbdevice name.

b- things like disk are composed of:
"disk" : "rest of disk arguments"

My plan was to add both of them as properties or similar. Any better idea? I can put it in one struct or similar, but it is not trivial to find where to put things really, because the "mouse" part is filled in usb-hid.c or equivalent, and the "disk" arguments part is filled in vl.c

Later, Juan.

#2 lore raw
Quoted 5 lines

What I want to do, to make usb modular I need two things:

a- a way to defino an alias, that "mouse" is equivalent to "QEMU USB
Keyboard". One is the qdev name and the other is the name passed to --usbdevice name.

I'm not too bothered about this. We're changing the option, so I don't see any particular problem with changing the device names at the same time.

Quoted 8 lines

b- things like disk are composed of:
"disk" : "rest of disk arguments"

My plan was to add both of them as properties or similar. Any better idea? I can put it in one struct or similar, but it is not trivial to find where to put things really, because the "mouse" part is filled in usb-hid.c or equivalent, and the "disk" arguments part is filled in vl.c

I think this is confusing host configuration with machine configuration. This has been discussed before.

Paul

#3 lore raw
Quoted 8 lines · Paul Brook
Quoted 5 lines

What I want to do, to make usb modular I need two things:

a- a way to defino an alias, that "mouse" is equivalent to "QEMU USB
Keyboard". One is the qdev name and the other is the name passed to --usbdevice name.

I'm not too bothered about this. We're changing the option, so I don't see any particular problem with changing the device names at the same time.

backward compatibility? Not that I care about this one really.

Quoted 11 lines
Quoted 8 lines

b- things like disk are composed of:
"disk" : "rest of disk arguments"

My plan was to add both of them as properties or similar. Any better idea? I can put it in one struct or similar, but it is not trivial to find where to put things really, because the "mouse" part is filled in usb-hid.c or equivalent, and the "disk" arguments part is filled in vl.c

I think this is confusing host configuration with machine configuration. This has been discussed before.

Yes, but it is the same problem. We are going to need something like:

-usb-hardawre name=bar,... -usbdevice disk:name=bar

or anything like that, the thing that I mean is that disk is going to have always a parameter (what disk we mean) and mouse is not going (necesarely)

Later, Juan.

#4 lore raw
Quoted 7 lines · Juan Quintela
Quoted 6 lines · Paul Brook
Quoted 5 lines

What I want to do, to make usb modular I need two things:

a- a way to defino an alias, that "mouse" is equivalent to "QEMU USB
Keyboard". One is the qdev name and the other is the name passed to --usbdevice name.

Quoted 5 lines
Quoted 3 lines

I'm not too bothered about this. We're changing the option, so I don't see any particular problem with changing the device names at the same time.

backward compatibility? Not that I care about this one really.

This is a new option. There's nothing to be backwards compatible with.

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

b- things like disk are composed of:
"disk" : "rest of disk arguments"

I think this is confusing host configuration with machine configuration. This has been discussed before.

Quoted 7 lines

Yes, but it is the same problem. We are going to need something like:

-usb-hardawre name=bar,... -usbdevice disk:name=bar

or anything like that, the thing that I mean is that disk is going to have always a parameter (what disk we mean) and mouse is not going (necesarely)

I'm not sure we're discussing the same thing here. "rest of disk arguments" should not be part of the USB device. The USB device should just have a link to a drive object, which is configured elsewhere (e.g. via a -drive option).

Paul

#5 lore raw
In reply to Juan Quintela
Quoted 9 lines · Juan Quintela
Quoted 8 lines · Gerd Hoffmann

Early RfC patch. Not functional yet. Just for comments right now.

Overall plan:
* drop property lists. The properties are saved directly in the device state structs instead.
* drop qdev_get_prop* functions, not needed any more.
* replace qdev_set_prop* functions by qdev_prop_{parse,set*}.

Quoted 8 lines
Quoted 6 lines

Done:
* added code to handle properties.

Todo:
* convert all the device drivers.
* actually drop the old functions.

Any good reason why you remove the list of propierties?

Pointless indirection and extra storage.
Note that this doesn't mean properties itself go away.

Quoted 3 lines

a- a way to defino an alias, that "mouse" is equivalent to "QEMU USB
Keyboard". One is the qdev name and the other is the name passed to --usbdevice name.

stick an alias next to name in DeviceInfo?
I don't see why this should use properties.

Quoted 2 lines

b- things like disk are composed of:
"disk" : "rest of disk arguments"

No. You'll create the host state from most of "rest of disk arguments".
You'll attach a name property to qdev so the driver has a handle to
lookup the host side of things.

cheers,
Gerd