diff mbox

[PULL,30/30] virtio: Convert exit to unrealize

Message ID CAJSP0QUVcNor4vjSfwXus88cJ-WTfwPP2-oCmFentzpANRhc7A@mail.gmail.com
State New
Headers show

Commit Message

Stefan Hajnoczi Dec. 19, 2013, 3:25 p.m. UTC
On Mon, Dec 9, 2013 at 9:48 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> From: Andreas Färber <afaerber@suse.de>
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/block/virtio-blk.c           | 10 ++++++----
>  hw/char/virtio-serial-bus.c     |  9 +++++----
>  hw/net/virtio-net.c             |  9 +++++----
>  hw/scsi/vhost-scsi.c            | 11 ++++++-----
>  hw/scsi/virtio-scsi.c           | 17 +++++++++--------
>  hw/virtio/virtio-balloon.c      |  9 +++++----
>  hw/virtio/virtio-rng.c          |  9 +++++----
>  hw/virtio/virtio.c              | 13 ++++++++-----
>  include/hw/virtio/virtio-scsi.h |  2 +-
>  include/hw/virtio/virtio.h      |  2 +-
>  10 files changed, 51 insertions(+), 40 deletions(-)

This commit breaks qemu-iotests 067:

067 1s ... - output mismatch (see 067.out.bad)
"event": "RESET"}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked":
false, "removable": true, "tray_open": false, "type": "unknown"},
{"device": "floppy0", "locked": false, "removable": true, "tray_open":
false, "type": "unknown"}, {"device": "sd0", "locked": false,
"removable": true, "tray_open": false, "type": "unknown"}]}
+{"return": [{"io-status": "ok", "device": "disk", "locked": false,
"removable": false, "inserted": {"iops_rd": 0, "image":
{"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2",
"cluster-size": 65536, "format": "qcow2", "actual-size": SIZE,
"format-specific": {"type": "qcow2", "data": {"compat": "1.1",
"lazy-refcounts": false}}, "dirty-flag": false}, "iops_wr": 0, "ro":
false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr":
0, "encrypted": false, "bps": 0, "bps_rd": 0, "file":
"TEST_DIR/t.qcow2", "encryption_key_missing": false}, "type":
"unknown"}, {"io-status": "ok", "device": "ide1-cd0", "locked": false,
"removable": true, "tray_open": false, "type": "unknown"}, {"device":
"floppy0", "locked": false, "removable": true, "tray_open": false,
"type": "unknown"}, {"device": "sd0", "locked": false, "removable":
true, "tray_open": false, "type": "unknown"}]}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP},
"event": "SHUTDOWN"}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP},
"event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0",
"tray-open": true}}

> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 1dba284..144b9ca 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -1169,12 +1169,15 @@ static void virtio_device_realize(DeviceState *dev, Error **errp)
>  static void virtio_device_unrealize(DeviceState *dev, Error **errp)
>  {
>      VirtIODevice *vdev = VIRTIO_DEVICE(dev);
> -    VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(dev);
> -
> -    virtio_bus_device_unplugged(vdev);
> +    VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev);
> +    Error *err = NULL;
>
> -    if (k->exit != NULL) {
> -        k->exit(vdev);
> +    if (vdc->unrealize != NULL) {
> +        vdc->unrealize(dev, &err);
> +        if (err != NULL) {
> +            error_propagate(errp, err);
> +            return;
> +        }
>      }

We no longer call virtio_bus_device_unplugged(dev).  I don't see it
called from anywhere else in the codebase!

Stefan

Comments

Paolo Bonzini Dec. 19, 2013, 3:32 p.m. UTC | #1
Il 19/12/2013 16:25, Stefan Hajnoczi ha scritto:
> On Mon, Dec 9, 2013 at 9:48 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> From: Andreas Färber <afaerber@suse.de>
>>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  hw/block/virtio-blk.c           | 10 ++++++----
>>  hw/char/virtio-serial-bus.c     |  9 +++++----
>>  hw/net/virtio-net.c             |  9 +++++----
>>  hw/scsi/vhost-scsi.c            | 11 ++++++-----
>>  hw/scsi/virtio-scsi.c           | 17 +++++++++--------
>>  hw/virtio/virtio-balloon.c      |  9 +++++----
>>  hw/virtio/virtio-rng.c          |  9 +++++----
>>  hw/virtio/virtio.c              | 13 ++++++++-----
>>  include/hw/virtio/virtio-scsi.h |  2 +-
>>  include/hw/virtio/virtio.h      |  2 +-
>>  10 files changed, 51 insertions(+), 40 deletions(-)
> 
> This commit breaks qemu-iotests 067:
> 
> 067 1s ... - output mismatch (see 067.out.bad)
> --- 067.out    2013-12-11 09:44:01.509447778 +0100
> +++ 067.out.bad    2013-12-19 16:02:39.582984141 +0100
> @@ -12,7 +12,7 @@
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP},
> "event": "DEVICE_DELETED", "data": {"path":
> "/machine/peripheral/virtio0/virtio-backend"}}
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP},
> "event": "DEVICE_DELETED", "data": {"device": "virtio0", "path":
> "/machine/peripheral/virtio0"}}
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP},
> "event": "RESET"}
> -{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked":
> false, "removable": true, "tray_open": false, "type": "unknown"},
> {"device": "floppy0", "locked": false, "removable": true, "tray_open":
> false, "type": "unknown"}, {"device": "sd0", "locked": false,
> "removable": true, "tray_open": false, "type": "unknown"}]}
> +{"return": [{"io-status": "ok", "device": "disk", "locked": false,
> "removable": false, "inserted": {"iops_rd": 0, "image":
> {"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2",
> "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE,
> "format-specific": {"type": "qcow2", "data": {"compat": "1.1",
> "lazy-refcounts": false}}, "dirty-flag": false}, "iops_wr": 0, "ro":
> false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr":
> 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file":
> "TEST_DIR/t.qcow2", "encryption_key_missing": false}, "type":
> "unknown"}, {"io-status": "ok", "device": "ide1-cd0", "locked": false,
> "removable": true, "tray_open": false, "type": "unknown"}, {"device":
> "floppy0", "locked": false, "removable": true, "tray_open": false,
> "type": "unknown"}, {"device": "sd0", "locked": false, "removable":
> true, "tray_open": false, "type": "unknown"}]}
>  {"return": {}}
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP},
> "event": "SHUTDOWN"}
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP},
> "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0",
> "tray-open": true}}
> 
>> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
>> index 1dba284..144b9ca 100644
>> --- a/hw/virtio/virtio.c
>> +++ b/hw/virtio/virtio.c
>> @@ -1169,12 +1169,15 @@ static void virtio_device_realize(DeviceState *dev, Error **errp)
>>  static void virtio_device_unrealize(DeviceState *dev, Error **errp)
>>  {
>>      VirtIODevice *vdev = VIRTIO_DEVICE(dev);
>> -    VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(dev);
>> -
>> -    virtio_bus_device_unplugged(vdev);
>> +    VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev);
>> +    Error *err = NULL;
>>
>> -    if (k->exit != NULL) {
>> -        k->exit(vdev);
>> +    if (vdc->unrealize != NULL) {
>> +        vdc->unrealize(dev, &err);
>> +        if (err != NULL) {
>> +            error_propagate(errp, err);
>> +            return;
>> +        }
>>      }
> 
> We no longer call virtio_bus_device_unplugged(dev).  I don't see it
> called from anywhere else in the codebase!

Ugh, that's a rebase snafu. :(  I'll send a patch tomorrow.

Paolo
diff mbox

Patch

--- 067.out    2013-12-11 09:44:01.509447778 +0100
+++ 067.out.bad    2013-12-19 16:02:39.582984141 +0100
@@ -12,7 +12,7 @@ 
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP},
"event": "DEVICE_DELETED", "data": {"path":
"/machine/peripheral/virtio0/virtio-backend"}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP},
"event": "DEVICE_DELETED", "data": {"device": "virtio0", "path":
"/machine/peripheral/virtio0"}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP},