Skip to contentSkip to conversation

Xen PV backend 'qdevification'

PATCH Superseded Paul Durrant 6 participants 119 messages Nov 21, 2018 – Dec 6, 2018 Page 2 of 2

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#93 lore raw

Re: [Qemu-devel] [PATCH 14/18] xen: add implementations of xen-qdisk connect and disconnect functions...

In reply to Paul Durrant

Am 29.11.2018 um 10:33 hat Paul Durrant geschrieben:

Quoted 137 lines
Quoted 130 lines

-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: 29 November 2018 09:01
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; xen- [email protected]; Stefano Stabellini <[email protected]>; Anthony Perard <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH 14/18] xen: add implementations of xen-qdisk connect and disconnect functions...

Am 28.11.2018 um 17:40 hat Paul Durrant geschrieben:

Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: 28 November 2018 16:35
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; xen- [email protected]; Stefano Stabellini

<[email protected]>;

Quoted 1 line
Quoted 1 line

Anthony Perard <[email protected]>; Max Reitz

<[email protected]>

Quoted 1 line
Quoted 1 line

Subject: Re: [PATCH 14/18] xen: add implementations of xen-qdisk

connect

Quoted 51 lines
Quoted 51 lines

and disconnect functions...

Am 21.11.2018 um 16:12 hat Paul Durrant geschrieben:

Quoted 8 lines

...and wire in the dataplane.

This patch adds the remaining code to make the xen-qdisk XenDevice functional. The parameters that a block frontend expects to find are populated in the backend xenstore area, and the 'ring-ref' and 'event-channel' values specified in the frontend xenstore area are mapped/bound and used to set up the dataplane.

Quoted 8 lines

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>

---
 hw/block/xen-qdisk.c       | 140

+++++++++++++++++++++++++++++++++++++++++++++

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice *xendev,

Quoted 21 lines
 hw/xen/xen-bus.c           |  12 ++--
 include/hw/xen/xen-bus.h   |   8 +++
 include/hw/xen/xen-qdisk.h |  12 ++++
 4 files changed, 166 insertions(+), 6 deletions(-)
hw/block/xen-qdisk.c +4 -0
index 35f7b70480..8c88393832 100644
@@ -9,6 +9,10 @@
 #include "qapi/visitor.h"
 #include "hw/hw.h"
 #include "hw/xen/xen-qdisk.h"
+#include "sysemu/blockdev.h"
+#include "sysemu/block-backend.h"
+#include "sysemu/iothread.h"
+#include "dataplane/xen-qdisk.h"
 #include "trace.h"
 
 static char *xen_qdisk_get_name(XenDevice *xendev, Error **errp)
@@ -23,6 +27,11 @@ static void xen_qdisk_realize(XenDevice *xendev,

Error **errp)

Quoted 9 lines
hw/block/xen-qdisk.c +5 -0
 {
     XenQdiskDevice *qdiskdev = XEN_QDISK_DEVICE(xendev);
     XenQdiskVdev *vdev = &qdiskdev->vdev;
+    BlockConf *conf = &qdiskdev->conf;
+    DriveInfo *dinfo;
+    bool is_cdrom;
+    unsigned int info;
+    int64_t size;
 
Quoted 3 lines
Quoted 3 lines

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice

Quoted 3 lines
hw/block/xen-qdisk.c +0 -0
     if (!vdev->valid) {
         error_setg(errp, "vdev property not set");
@@ -30,13 +39,134 @@ static void xen_qdisk_realize(XenDevice

*xendev,

Quoted 16 lines
Quoted 16 lines

Error **errp)

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice *xendev, Error **errp) · line 51

Quoted 13 lines
hw/block/xen-qdisk.c +10 -0
     }
 
     trace_xen_qdisk_realize(vdev->disk, vdev->partition);
+
+    if (!conf->blk) {
+        error_setg(errp, "drive property not set");
+        return;
+    }
+
+    if (!blk_is_inserted(conf->blk)) {
+        error_setg(errp, "device needs media, but drive is empty");
+        return;
+    }

Hm, the code below suggests that you support CD-ROMs. Don't you want

to

Quoted 4 lines
Quoted 2 lines

support media change as well then? Which would mean that you need to support empty drives.

Yes, that's a good point. I should get rid of that check.

Or rather apply it only to hard disks. And for empty CDs, you'll probably need to create an empty BlockBackend (the !conf->blk case). Just check the IDE and/or SCSI code for comparison.

Quoted 16 lines
Quoted 16 lines

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice *xendev, Error **errp) · line 63

Quoted 13 lines
hw/block/xen-qdisk.c +11 -0
+    if (!blkconf_apply_backend_options(conf, blk_is_read_only(conf-
 blk),
+                                       false, errp)) {
+        return;
+    }
+
+    if (!blkconf_geometry(conf, NULL, 65535, 255, 255, errp)) {
+        return;
+    }
+
+    dinfo = blk_legacy_dinfo(conf->blk);
+    is_cdrom = (dinfo && dinfo->media_cd);

It's called legacy for a reason. Don't use this in new devices.

Quoted 5 lines
Quoted 2 lines

The proper way is to have two different devices for hard disks and CDs (like scsi-hd and scsi-cd).

...or presumably I could have a property? The legacy init code could then set it based on the drive info.

Technically yes, but why would that be a good way to model things? I mean, it's true that xen-qdisk is not real hardware, but I've never seen any hardware that has a switch to decide whether it should behave as a CD drive or a hard disk.

Quoted 6 lines

Both have very different characteristics (read-only with removable media, or a single read-write disk), and the existing implementations use two separate devices. So even if you're not convinced that users will consider them different concepts (I am; and if they weren't different concepts, you wouldn't need an is_cdrom variable), consistency is still a good thing.

Quoted 2 lines

Ok. I'll split the device as you suggest... it may mean duplicated code, but the datapath can still be common.

If you have a look at IDE and SCSI, they don't really duplicate a lot of code. Basically it's just a second QOM class definition, the rest is shared. Even the realize functions are essentially shared, with just two small wrappers for each device type around the common code.

Kevin

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#94 lore raw

Re: [PATCH 14/18] xen: add implementations of xen-qdisk connect and disconnect functions...

Quoted 163 lines

-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: 29 November 2018 10:46
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; xen- [email protected]; Stefano Stabellini <[email protected]>; Anthony Perard <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH 14/18] xen: add implementations of xen-qdisk connect and disconnect functions...

Am 29.11.2018 um 10:33 hat Paul Durrant geschrieben:

Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: 29 November 2018 09:01
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; xen- [email protected]; Stefano Stabellini

<[email protected]>;

Quoted 1 line
Quoted 1 line

Anthony Perard <[email protected]>; Max Reitz

<[email protected]>

Quoted 1 line
Quoted 1 line

Subject: Re: [PATCH 14/18] xen: add implementations of xen-qdisk

connect

Quoted 12 lines
Quoted 12 lines

and disconnect functions...

Am 28.11.2018 um 17:40 hat Paul Durrant geschrieben:

Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: 28 November 2018 16:35
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; xen- [email protected]; Stefano Stabellini

<[email protected]>;

Quoted 1 line
Quoted 1 line

Anthony Perard <[email protected]>; Max Reitz

<[email protected]>

Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line

Subject: Re: [PATCH 14/18] xen: add implementations of xen-qdisk

connect

Quoted 6 lines
Quoted 6 lines

and disconnect functions...

Am 21.11.2018 um 16:12 hat Paul Durrant geschrieben:

Quoted 3 lines

...and wire in the dataplane.

This patch adds the remaining code to make the xen-qdisk

XenDevice

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

functional. The parameters that a block frontend expects to find

are

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

populated in the backend xenstore area, and the 'ring-ref' and 'event-channel' values specified in the frontend xenstore area

are

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 10 lines

mapped/bound and used to set up the dataplane.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>

---
 hw/block/xen-qdisk.c       | 140

+++++++++++++++++++++++++++++++++++++++++++++

Quoted 19 lines
 hw/xen/xen-bus.c           |  12 ++--
 include/hw/xen/xen-bus.h   |   8 +++
 include/hw/xen/xen-qdisk.h |  12 ++++
 4 files changed, 166 insertions(+), 6 deletions(-)
hw/block/xen-qdisk.c +4 -0
index 35f7b70480..8c88393832 100644
@@ -9,6 +9,10 @@
 #include "qapi/visitor.h"
 #include "hw/hw.h"
 #include "hw/xen/xen-qdisk.h"
+#include "sysemu/blockdev.h"
+#include "sysemu/block-backend.h"
+#include "sysemu/iothread.h"
+#include "dataplane/xen-qdisk.h"
 #include "trace.h"
 
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

hw/block/xen-qdisk.c line 18

Quoted 1 line
hw/block/xen-qdisk.c +0 -0
 static char *xen_qdisk_get_name(XenDevice *xendev, Error

**errp)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice

Quoted 1 line
hw/block/xen-qdisk.c +0 -0
@@ -23,6 +27,11 @@ static void xen_qdisk_realize(XenDevice

*xendev,

Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 10 lines

Error **errp)

Quoted 9 lines
hw/block/xen-qdisk.c +5 -0
 {
     XenQdiskDevice *qdiskdev = XEN_QDISK_DEVICE(xendev);
     XenQdiskVdev *vdev = &qdiskdev->vdev;
+    BlockConf *conf = &qdiskdev->conf;
+    DriveInfo *dinfo;
+    bool is_cdrom;
+    unsigned int info;
+    int64_t size;
 
Quoted 3 lines
Quoted 3 lines

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice

Quoted 3 lines
hw/block/xen-qdisk.c +0 -0
     if (!vdev->valid) {
         error_setg(errp, "vdev property not set");
@@ -30,13 +39,134 @@ static void xen_qdisk_realize(XenDevice

*xendev,

Quoted 3 lines
Quoted 3 lines

Error **errp)

Quoted 2 lines
hw/block/xen-qdisk.c +0 -0
     }
 
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice *xendev, Error **errp)

Quoted 9 lines
hw/block/xen-qdisk.c +8 -0
     trace_xen_qdisk_realize(vdev->disk, vdev->partition);
+
+    if (!conf->blk) {
+        error_setg(errp, "drive property not set");
+        return;
+    }
+
+    if (!blk_is_inserted(conf->blk)) {
+        error_setg(errp, "device needs media, but drive is

empty");

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice · line 51

Quoted 2 lines
hw/block/xen-qdisk.c +2 -0
+        return;
+    }

Hm, the code below suggests that you support CD-ROMs. Don't you

want

Quoted 2 lines
Quoted 2 lines

to

Quoted 1 line
Quoted 1 line

support media change as well then? Which would mean that you need

to

Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Quoted 1 line

support empty drives.

Yes, that's a good point. I should get rid of that check.

Or rather apply it only to hard disks. And for empty CDs, you'll probably need to create an empty BlockBackend (the !conf->blk case). Just check the IDE and/or SCSI code for comparison.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
hw/block/xen-qdisk.c +1 -0
+    if (!blkconf_apply_backend_options(conf,

blk_is_read_only(conf-

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice *xendev, Error **errp) · line 63

Quoted 11 lines
hw/block/xen-qdisk.c +10 -0
 blk),
+                                       false, errp)) {
+        return;
+    }
+
+    if (!blkconf_geometry(conf, NULL, 65535, 255, 255, errp)) {
+        return;
+    }
+
+    dinfo = blk_legacy_dinfo(conf->blk);
+    is_cdrom = (dinfo && dinfo->media_cd);

It's called legacy for a reason. Don't use this in new devices.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

The proper way is to have two different devices for hard disks and

CDs

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

(like scsi-hd and scsi-cd).

...or presumably I could have a property? The legacy init code could then set it based on the drive info.

Technically yes, but why would that be a good way to model things? I mean, it's true that xen-qdisk is not real hardware, but I've never

seen

Quoted 8 lines
Quoted 8 lines

any hardware that has a switch to decide whether it should behave as a CD drive or a hard disk.

Both have very different characteristics (read-only with removable media, or a single read-write disk), and the existing implementations use two separate devices. So even if you're not convinced that users will consider them different concepts (I am; and if they weren't different concepts, you wouldn't need an is_cdrom variable),

consistency

Quoted 2 lines
Quoted 1 line

is still a good thing.

Quoted 7 lines
Quoted 2 lines

Ok. I'll split the device as you suggest... it may mean duplicated code, but the datapath can still be common.

If you have a look at IDE and SCSI, they don't really duplicate a lot of code. Basically it's just a second QOM class definition, the rest is shared. Even the realize functions are essentially shared, with just two small wrappers for each device type around the common code.

Ok, I was hoping the duplication would be limited to something like that :-) I'll try to follow suit.

Paul

Quoted 2 lines

Kevin

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#95 lore raw

Re: [Qemu-devel] [PATCH 14/18] xen: add implementations of xen-qdisk connect and disconnect functions...

In reply to Kevin Wolf
Quoted 163 lines

-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: 29 November 2018 10:46
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; xen- [email protected]; Stefano Stabellini <[email protected]>; Anthony Perard <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH 14/18] xen: add implementations of xen-qdisk connect and disconnect functions...

Am 29.11.2018 um 10:33 hat Paul Durrant geschrieben:

Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: 29 November 2018 09:01
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; xen- [email protected]; Stefano Stabellini

<[email protected]>;

Quoted 1 line
Quoted 1 line

Anthony Perard <[email protected]>; Max Reitz

<[email protected]>

Quoted 1 line
Quoted 1 line

Subject: Re: [PATCH 14/18] xen: add implementations of xen-qdisk

connect

Quoted 12 lines
Quoted 12 lines

and disconnect functions...

Am 28.11.2018 um 17:40 hat Paul Durrant geschrieben:

Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: 28 November 2018 16:35
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; xen- [email protected]; Stefano Stabellini

<[email protected]>;

Quoted 1 line
Quoted 1 line

Anthony Perard <[email protected]>; Max Reitz

<[email protected]>

Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line

Subject: Re: [PATCH 14/18] xen: add implementations of xen-qdisk

connect

Quoted 6 lines
Quoted 6 lines

and disconnect functions...

Am 21.11.2018 um 16:12 hat Paul Durrant geschrieben:

Quoted 3 lines

...and wire in the dataplane.

This patch adds the remaining code to make the xen-qdisk

XenDevice

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

functional. The parameters that a block frontend expects to find

are

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

populated in the backend xenstore area, and the 'ring-ref' and 'event-channel' values specified in the frontend xenstore area

are

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 10 lines

mapped/bound and used to set up the dataplane.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>

---
 hw/block/xen-qdisk.c       | 140

+++++++++++++++++++++++++++++++++++++++++++++

Quoted 19 lines
 hw/xen/xen-bus.c           |  12 ++--
 include/hw/xen/xen-bus.h   |   8 +++
 include/hw/xen/xen-qdisk.h |  12 ++++
 4 files changed, 166 insertions(+), 6 deletions(-)
hw/block/xen-qdisk.c +4 -0
index 35f7b70480..8c88393832 100644
@@ -9,6 +9,10 @@
 #include "qapi/visitor.h"
 #include "hw/hw.h"
 #include "hw/xen/xen-qdisk.h"
+#include "sysemu/blockdev.h"
+#include "sysemu/block-backend.h"
+#include "sysemu/iothread.h"
+#include "dataplane/xen-qdisk.h"
 #include "trace.h"
 
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

hw/block/xen-qdisk.c line 18

Quoted 1 line
hw/block/xen-qdisk.c +0 -0
 static char *xen_qdisk_get_name(XenDevice *xendev, Error

**errp)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice

Quoted 1 line
hw/block/xen-qdisk.c +0 -0
@@ -23,6 +27,11 @@ static void xen_qdisk_realize(XenDevice

*xendev,

Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 10 lines

Error **errp)

Quoted 9 lines
hw/block/xen-qdisk.c +5 -0
 {
     XenQdiskDevice *qdiskdev = XEN_QDISK_DEVICE(xendev);
     XenQdiskVdev *vdev = &qdiskdev->vdev;
+    BlockConf *conf = &qdiskdev->conf;
+    DriveInfo *dinfo;
+    bool is_cdrom;
+    unsigned int info;
+    int64_t size;
 
Quoted 3 lines
Quoted 3 lines

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice

Quoted 3 lines
hw/block/xen-qdisk.c +0 -0
     if (!vdev->valid) {
         error_setg(errp, "vdev property not set");
@@ -30,13 +39,134 @@ static void xen_qdisk_realize(XenDevice

*xendev,

Quoted 3 lines
Quoted 3 lines

Error **errp)

Quoted 2 lines
hw/block/xen-qdisk.c +0 -0
     }
 
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice *xendev, Error **errp)

Quoted 9 lines
hw/block/xen-qdisk.c +8 -0
     trace_xen_qdisk_realize(vdev->disk, vdev->partition);
+
+    if (!conf->blk) {
+        error_setg(errp, "drive property not set");
+        return;
+    }
+
+    if (!blk_is_inserted(conf->blk)) {
+        error_setg(errp, "device needs media, but drive is

empty");

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice · line 51

Quoted 2 lines
hw/block/xen-qdisk.c +2 -0
+        return;
+    }

Hm, the code below suggests that you support CD-ROMs. Don't you

want

Quoted 2 lines
Quoted 2 lines

to

Quoted 1 line
Quoted 1 line

support media change as well then? Which would mean that you need

to

Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Quoted 1 line

support empty drives.

Yes, that's a good point. I should get rid of that check.

Or rather apply it only to hard disks. And for empty CDs, you'll probably need to create an empty BlockBackend (the !conf->blk case). Just check the IDE and/or SCSI code for comparison.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
hw/block/xen-qdisk.c +1 -0
+    if (!blkconf_apply_backend_options(conf,

blk_is_read_only(conf-

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice *xendev, Error **errp) · line 63

Quoted 11 lines
hw/block/xen-qdisk.c +10 -0
 blk),
+                                       false, errp)) {
+        return;
+    }
+
+    if (!blkconf_geometry(conf, NULL, 65535, 255, 255, errp)) {
+        return;
+    }
+
+    dinfo = blk_legacy_dinfo(conf->blk);
+    is_cdrom = (dinfo && dinfo->media_cd);

It's called legacy for a reason. Don't use this in new devices.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

The proper way is to have two different devices for hard disks and

CDs

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

(like scsi-hd and scsi-cd).

...or presumably I could have a property? The legacy init code could then set it based on the drive info.

Technically yes, but why would that be a good way to model things? I mean, it's true that xen-qdisk is not real hardware, but I've never

seen

Quoted 8 lines
Quoted 8 lines

any hardware that has a switch to decide whether it should behave as a CD drive or a hard disk.

Both have very different characteristics (read-only with removable media, or a single read-write disk), and the existing implementations use two separate devices. So even if you're not convinced that users will consider them different concepts (I am; and if they weren't different concepts, you wouldn't need an is_cdrom variable),

consistency

Quoted 2 lines
Quoted 1 line

is still a good thing.

Quoted 7 lines
Quoted 2 lines

Ok. I'll split the device as you suggest... it may mean duplicated code, but the datapath can still be common.

If you have a look at IDE and SCSI, they don't really duplicate a lot of code. Basically it's just a second QOM class definition, the rest is shared. Even the realize functions are essentially shared, with just two small wrappers for each device type around the common code.

Ok, I was hoping the duplication would be limited to something like that :-) I'll try to follow suit.

Paul

Quoted 2 lines

Kevin

#96 lore raw

Re: [Qemu-devel] [PATCH 14/18] xen: add implementations of xen-qdisk connect and disconnect functions...

In reply to Paul Durrant
Quoted 11 lines · Paul Durrant
hw/block/xen-qdisk.c +3 -0
index 35f7b70480..8c88393832 100644
 static void xen_qdisk_connect(XenQdiskDevice *qdiskdev, Error **errp)
 {
     XenQdiskVdev *vdev = &qdiskdev->vdev;
+    XenDevice *xendev = XEN_DEVICE(qdiskdev);
+    unsigned int order, nr_ring_ref, *ring_ref, event_channel, protocol;
+    char *str;
 

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice *xendev, Error **errp) · line 119

Quoted 10 lines
hw/block/xen-qdisk.c +9 -0
     trace_xen_qdisk_connect(vdev->disk, vdev->partition);
+
+    if (xen_device_frontend_scanf(xendev, "ring-page-order", "%u",
+                                  &order) != 1) {
+        nr_ring_ref = 1;
+        ring_ref = g_new(unsigned int, nr_ring_ref);
+
+        if (xen_device_frontend_scanf(xendev, "ring-ref", "%u",
+                                      &ring_ref[0]) != 1) {
+            error_setg(errp, "failed to read ring-ref");

Don't you need to free ring_ref?

Quoted 2 lines
hw/block/xen-qdisk.c +2 -0
+            return;
+        }

[...]

Quoted 7 lines
include/hw/xen/xen-qdisk.h +0 -0
index ade0866037..d7dd2bf0ee 100644
@@ -6,7 +6,15 @@
 #ifndef HW_XEN_QDISK_H
 #define HW_XEN_QDISK_H

include/hw/xen/xen-qdisk.h line 17

Quoted 10 lines
include/hw/xen/xen-qdisk.h +8 -0
 
+#include "hw/xen/xen.h"
 #include "hw/xen/xen-bus.h"
+#include "hw/block/block.h"
+#include "hw/block/xen_blkif.h"
+#include "hw/block/dataplane/xen-qdisk.h"
+#include "sysemu/blockdev.h"
+#include "sysemu/iothread.h"
+#include "sysemu/block-backend.h"
+#include "sysemu/iothread.h"

You don't need that many includes, especially not iothread.h twice ;-).

I think those new includes would be enough:
#include "hw/block/block.h"; for BlockConf
#include "sysemu/iothread.h"
#include "hw/block/dataplane/xen-qdisk.h"

Quoted 14 lines
include/hw/xen/xen-qdisk.h +4 -0
 typedef enum XenQdiskVdevType {
     XEN_QDISK_VDEV_TYPE_DP,
@@ -33,6 +41,10 @@ typedef struct XenQdiskDevice XenQdiskDevice;
 struct XenQdiskDevice {
     XenDevice xendev;
     XenQdiskVdev vdev;
+    BlockConf conf;
+    unsigned int max_ring_page_order;
+    IOThread *iothread;
+    XenQdiskDataPlane *dataplane;
 };
 
 #endif /* HW_XEN_QDISK_H */
Signature · 1 line
Anthony PERARD
#97 lore raw

Re: [Qemu-devel] [PATCH 14/18] xen: add implementations of xen-qdisk connect and disconnect functions...

Quoted 23 lines

-----Original Message-----
From: Anthony PERARD [mailto:[email protected]]
Sent: 04 December 2018 12:34
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; xen- [email protected]; Stefano Stabellini <[email protected]>; Kevin Wolf <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH 14/18] xen: add implementations of xen-qdisk connect and disconnect functions...

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice *xendev, Error **errp)

Quoted 9 lines · Paul Durrant
hw/block/xen-qdisk.c +2 -0
index 35f7b70480..8c88393832 100644
 static void xen_qdisk_connect(XenQdiskDevice *qdiskdev, Error **errp)
 {
     XenQdiskVdev *vdev = &qdiskdev->vdev;
+    XenDevice *xendev = XEN_DEVICE(qdiskdev);
+    unsigned int order, nr_ring_ref, *ring_ref, event_channel,

protocol;

Quoted 2 lines

+ char *str;

Quoted 12 lines

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice *xendev, Error **errp) · line 119

Quoted 10 lines
     trace_xen_qdisk_connect(vdev->disk, vdev->partition);
hw/block/xen-qdisk.c +9 -0
+
+    if (xen_device_frontend_scanf(xendev, "ring-page-order", "%u",
+                                  &order) != 1) {
+        nr_ring_ref = 1;
+        ring_ref = g_new(unsigned int, nr_ring_ref);
+
+        if (xen_device_frontend_scanf(xendev, "ring-ref", "%u",
+                                      &ring_ref[0]) != 1) {
+            error_setg(errp, "failed to read ring-ref");

Don't you need to free ring_ref?

Yes.

Quoted 13 lines
Quoted 3 lines
hw/block/xen-qdisk.c +2 -0
+            return;
+        }

[...]

Quoted 8 lines
include/hw/xen/xen-qdisk.h +0 -0
index ade0866037..d7dd2bf0ee 100644
@@ -6,7 +6,15 @@
 #ifndef HW_XEN_QDISK_H
 #define HW_XEN_QDISK_H
 
Quoted 12 lines

include/hw/xen/xen-qdisk.h line 17

Quoted 9 lines
include/hw/xen/xen-qdisk.h +8 -0
+#include "hw/xen/xen.h"
 #include "hw/xen/xen-bus.h"
+#include "hw/block/block.h"
+#include "hw/block/xen_blkif.h"
+#include "hw/block/dataplane/xen-qdisk.h"
+#include "sysemu/blockdev.h"
+#include "sysemu/iothread.h"
+#include "sysemu/block-backend.h"
+#include "sysemu/iothread.h"

You don't need that many includes, especially not iothread.h twice ;-).

Oops.

Quoted 5 lines

I think those new includes would be enough:
#include "hw/block/block.h"; for BlockConf
#include "sysemu/iothread.h"
#include "hw/block/dataplane/xen-qdisk.h"

Yes, those seem to be enough.

Paul

Quoted 13 lines
Quoted 13 lines
include/hw/xen/xen-qdisk.h +4 -0
 typedef enum XenQdiskVdevType {
     XEN_QDISK_VDEV_TYPE_DP,
@@ -33,6 +41,10 @@ typedef struct XenQdiskDevice XenQdiskDevice;
 struct XenQdiskDevice {
     XenDevice xendev;
     XenQdiskVdev vdev;
+    BlockConf conf;
+    unsigned int max_ring_page_order;
+    IOThread *iothread;
+    XenQdiskDataPlane *dataplane;
 };
 
Quoted 4 lines

include/hw/xen/xen-qdisk.h typedef struct XenQdiskDevice XenQdiskDevice; · line 50

Quoted 1 line
include/hw/xen/xen-qdisk.h +0 -0
 #endif /* HW_XEN_QDISK_H */

--
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#98 lore raw

Re: [PATCH 14/18] xen: add implementations of xen-qdisk connect and disconnect functions...

In reply to Paul Durrant
Quoted 11 lines · Paul Durrant
hw/block/xen-qdisk.c +3 -0
index 35f7b70480..8c88393832 100644
 static void xen_qdisk_connect(XenQdiskDevice *qdiskdev, Error **errp)
 {
     XenQdiskVdev *vdev = &qdiskdev->vdev;
+    XenDevice *xendev = XEN_DEVICE(qdiskdev);
+    unsigned int order, nr_ring_ref, *ring_ref, event_channel, protocol;
+    char *str;
 

hw/block/xen-qdisk.c static void xen_qdisk_realize(XenDevice *xendev, Error **errp) · line 119

Quoted 10 lines
hw/block/xen-qdisk.c +9 -0
     trace_xen_qdisk_connect(vdev->disk, vdev->partition);
+
+    if (xen_device_frontend_scanf(xendev, "ring-page-order", "%u",
+                                  &order) != 1) {
+        nr_ring_ref = 1;
+        ring_ref = g_new(unsigned int, nr_ring_ref);
+
+        if (xen_device_frontend_scanf(xendev, "ring-ref", "%u",
+                                      &ring_ref[0]) != 1) {
+            error_setg(errp, "failed to read ring-ref");

Don't you need to free ring_ref?

Quoted 2 lines
hw/block/xen-qdisk.c +2 -0
+            return;
+        }

[...]

Quoted 7 lines
include/hw/xen/xen-qdisk.h +0 -0
index ade0866037..d7dd2bf0ee 100644
@@ -6,7 +6,15 @@
 #ifndef HW_XEN_QDISK_H
 #define HW_XEN_QDISK_H

include/hw/xen/xen-qdisk.h line 17

Quoted 10 lines
include/hw/xen/xen-qdisk.h +8 -0
 
+#include "hw/xen/xen.h"
 #include "hw/xen/xen-bus.h"
+#include "hw/block/block.h"
+#include "hw/block/xen_blkif.h"
+#include "hw/block/dataplane/xen-qdisk.h"
+#include "sysemu/blockdev.h"
+#include "sysemu/iothread.h"
+#include "sysemu/block-backend.h"
+#include "sysemu/iothread.h"

You don't need that many includes, especially not iothread.h twice ;-).

I think those new includes would be enough:
#include "hw/block/block.h"; for BlockConf
#include "sysemu/iothread.h"
#include "hw/block/dataplane/xen-qdisk.h"

Quoted 14 lines
include/hw/xen/xen-qdisk.h +4 -0
 typedef enum XenQdiskVdevType {
     XEN_QDISK_VDEV_TYPE_DP,
@@ -33,6 +41,10 @@ typedef struct XenQdiskDevice XenQdiskDevice;
 struct XenQdiskDevice {
     XenDevice xendev;
     XenQdiskVdev vdev;
+    BlockConf conf;
+    unsigned int max_ring_page_order;
+    IOThread *iothread;
+    XenQdiskDataPlane *dataplane;
 };
 
 #endif /* HW_XEN_QDISK_H */
Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#99 lore raw

PATCH 15/18 xen: add a mechanism to automatically create XenDevice-s...

In reply to Paul Durrant

...that maintains compatibility with existing Xen toolstacks.

Xen toolstacks instantiate PV backends by simply writing information into xenstore and expecting a backend implementation to be watching for this.

This patch adds a new 'xen-backend' module to allow individual XenDevice implementations to register a creator function to be called when a tool- stack instantiates a new backend in this way.

To support this it is also necessary to add new watchers into the XenBus implementation to handle enumeration of new backends and also destruction of XenDevice-s when the toolstack sets the backend 'online' key to 0.

NOTE: This patch only adds the framework. A subsequent patch will add a
creator function for xen-qdisk.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

---
 hw/xen/Makefile.objs         |   2 +-
 hw/xen/trace-events          |   5 +
 hw/xen/xen-backend.c         |  67 +++++++++++++
 hw/xen/xen-bus.c             | 220 +++++++++++++++++++++++++++++++++++++++----
 include/hw/xen/xen-backend.h |  24 +++++
 include/hw/xen/xen-bus.h     |   5 +-
 include/qemu/module.h        |   3 +
 7 files changed, 305 insertions(+), 21 deletions(-)
 create mode 100644 hw/xen/xen-backend.c
 create mode 100644 include/hw/xen/xen-backend.h
hw/xen/Makefile.objs +1 -1
index 77c0868190..84df60a928 100644
@@ -1,5 +1,5 @@
 # xen backend driver support
-common-obj-$(CONFIG_XEN) += xen-legacy-backend.o xen_devconfig.o xen_pvdev.o xen-common.o xen-bus.o xen-bus-helper.o
+common-obj-$(CONFIG_XEN) += xen-legacy-backend.o xen_devconfig.o xen_pvdev.o xen-common.o xen-bus.o xen-bus-helper.o xen-backend.o
 
 obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o
 obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_graphics.o xen_pt_msi.o
hw/xen/trace-events +5 -0
index 94c46c2e34..5b12135083 100644
@@ -16,11 +16,16 @@ xen_domid_restrict(int err) "err: %u"
 # include/hw/xen/xen-bus.c
 xen_bus_realize(void) ""
 xen_bus_unrealize(void) ""
+xen_bus_enumerate(void) ""
+xen_bus_type_enumerate(const char *type) "type: %s"
+xen_bus_backend_create(const char *type, const char *path) "type: %s path: %s"
 xen_bus_add_watch(const char *node, const char *key, char *token) "node: %s key: %s token: %s"
 xen_bus_remove_watch(const char *node, const char *key, char *token) "node: %s key: %s token: %s"
 xen_bus_watch(const char *token) "token: %s"
 xen_device_realize(const char *type, char *name) "type: %s name: %s"
 xen_device_unrealize(const char *type, char *name) "type: %s name: %s"
 xen_device_backend_state(const char *type, char *name, const char *state) "type: %s name: %s -> %s"
+xen_device_backend_online(const char *type, char *name, bool online) "type: %s name: %s -> %u"
 xen_device_frontend_state(const char *type, char *name, const char *state) "type: %s name: %s -> %s"
+xen_device_backend_changed(const char *type, char *name) "type: %s name: %s"
 xen_device_frontend_changed(const char *type, char *name) "type: %s name: %s"
hw/xen/xen-backend.c new file +67 -0

67 lines not on this page · raw message

hw/xen/xen-bus.c +201 -19

286 lines not on this page · raw message

include/hw/xen/xen-backend.h new file +24 -0
new file mode 100644
index 0000000000..ca5ae34398
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) Citrix Systems Inc.
+ * All rights reserved.
+ */
+
+#ifndef HW_XEN_BACKEND_H
+#define HW_XEN_BACKEND_H
+
+#include "hw/xen/xen-bus.h"
+
+typedef void (*XenBackendDeviceCreate)(BusState *bus, const char *name,
+                                       QDict *opts, Error **errp);
+
+typedef struct XenBackendInfo {
+    const char *type;
+    XenBackendDeviceCreate create;
+} XenBackendInfo;
+
+void xen_backend_register(const XenBackendInfo *info);
+
+void xen_backend_device_create(BusState *bus, const char *type,
+                               const char *name, QDict *opts, Error **errp);
+
+#endif /* HW_XEN_BACKEND_H */
include/hw/xen/xen-bus.h +4 -1
index d931e01268..48f3e068d3 100644
@@ -21,7 +21,9 @@ typedef struct XenDevice {
     char *backend_path, *frontend_path;
     enum xenbus_state backend_state, frontend_state;
     Notifier exit;
-    XenWatch *frontend_state_watch;
+    XenWatch *backend_state_watch, *frontend_state_watch;
+    bool backend_online;
+    XenWatch *backend_online_watch;
     xengnttab_handle *xgth;
     bool feature_grant_copy;
     xenevtchn_handle *xeh;
@@ -61,6 +63,7 @@ typedef struct XenBus {
     domid_t backend_id;
     struct xs_handle *xsh;
     NotifierList watch_notifiers;
+    XenWatch *backend_watch;
 } XenBus;
 
 typedef struct XenBusClass {
include/qemu/module.h +3 -0
index 54300ab6e5..55dd2beea8 100644
@@ -44,6 +44,7 @@ typedef enum {
     MODULE_INIT_OPTS,
     MODULE_INIT_QOM,
     MODULE_INIT_TRACE,
+    MODULE_INIT_XEN_BACKEND,
     MODULE_INIT_MAX
 } module_init_type;
 
@@ -51,6 +52,8 @@ typedef enum {
 #define opts_init(function) module_init(function, MODULE_INIT_OPTS)
 #define type_init(function) module_init(function, MODULE_INIT_QOM)
 #define trace_init(function) module_init(function, MODULE_INIT_TRACE)
+#define xen_backend_init(function) module_init(function, \
+                                               MODULE_INIT_XEN_BACKEND)
 
 #define block_module_load_one(lib) module_load_one("block-", lib)
 #define ui_module_load_one(lib) module_load_one("ui-", lib)
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#100 lore raw

Re: [Qemu-devel] [PATCH 15/18] xen: add a mechanism to automatically create XenDevice-s...

hw/xen/xen-bus.c static void xen_bus_remove_watch(XenBus *xenbus, XenWatch *watch) · line 182

Quoted 9 lines · Paul Durrant
hw/xen/xen-bus.c +9 -0
+    xen_backend_device_create(BUS(xenbus), type, name, opts, &local_err);
+    qobject_unref(opts);
+
+    if (local_err) {
+        const char *msg = error_get_pretty(local_err);
+
+        error_report("failed to create '%s' device '%s': %s", type, name,
+                     msg);
+        error_free(local_err);

You can use error_reportf_err() instead of those three calls. I may have only suggest error_report_err in a previous patch, but error_reportf_err does the error_prepend as well.

hw/xen/xen-bus.c static void xen_bus_remove_watch(XenBus *xenbus, XenWatch *watch) · line 195

Quoted 13 lines
hw/xen/xen-bus.c +13 -0
+    }
+}
+
+static void xen_bus_type_enumerate(XenBus *xenbus, const char *type)
+{
+    char *domain_path = g_strdup_printf("backend/%s/%u", type, xen_domid);
+    char **backend;
+    unsigned int i, n;
+
+    trace_xen_bus_type_enumerate(type);
+
+    backend = xs_directory(xenbus->xsh, XBT_NULL, domain_path, &n);
+    if (!backend) {

domain_path isn't free here, you probably want a goto out which would free everything.

Quoted 6 lines
hw/xen/xen-bus.c +3 -0
+        return;
+    }
+
@@ -193,6 +302,17 @@ static void xen_bus_realize(BusState *bus, Error **errp)
     notifier_list_init(&xenbus->watch_notifiers);
     qemu_set_fd_handler(xs_fileno(xenbus->xsh), xen_bus_watch, NULL,

hw/xen/xen-bus.c static void xen_bus_realize(BusState *bus, Error **errp) · line 313

Quoted 10 lines
hw/xen/xen-bus.c +9 -0
                         xenbus);
+
+    module_call_init(MODULE_INIT_XEN_BACKEND);
+
+    xenbus->backend_watch =
+        xen_bus_add_watch(xenbus, "", /* domain root node */
+                          "backend", xen_bus_enumerate, xenbus, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        error_prepend(errp, "failed to set up enumeration watch: ");

You should use error_propagate_prepend instead error_propagate;error_prepend. And it looks like there is the same mistake in other patches that I haven't notice.

Also you probably want goto fail here.

Quoted 4 lines
hw/xen/xen-bus.c +4 -0
+static void xen_device_backend_changed(void *opaque)
+{
+    XenDevice *xendev = opaque;
+    const char *type = object_get_typename(OBJECT(xendev));

hw/xen/xen-bus.c enum xenbus_state xen_device_backend_get_state(XenDevice *xendev) · line 418

Quoted 10 lines
hw/xen/xen-bus.c +10 -0
+    enum xenbus_state state;
+    unsigned int online;
+
+    trace_xen_device_backend_changed(type, xendev->name);
+
+    if (xen_device_backend_scanf(xendev, "state", "%u", &state) != 1) {
+        state = XenbusStateUnknown;
+    }
+
+    xen_device_backend_set_state(xendev, state);

It's kind of weird to set the internal state base on the external one that something else may have modified. Shouldn't we check that it is fine for something else to modify the state and that it is a correct transition?

Also aren't we going in a loop by having QEMU set the state, then the watch fires again? (Not really a loop since the function _set_state check for changes.

Also maybe we should watch for the state changes only when something else like libxl creates (ask for) the backend, and ignore changes when QEMU did it itself.

hw/xen/xen-bus.c enum xenbus_state xen_device_backend_get_state(XenDevice *xendev) · line 431

Quoted 13 lines
hw/xen/xen-bus.c +13 -0
+
+    if (xen_device_backend_scanf(xendev, "online", "%u", &online) != 1) {
+        online = 0;
+    }
+
+    xen_device_backend_set_online(xendev, !!online);
+
+    /*
+     * If a backend is still 'online' then its state should be cycled
+     * back round to InitWait in order for a new frontend instance to
+     * connect. This may happen when, for example, a frontend driver is
+     * re-installed or updated.
+     * If a backend id not 'online' then the device should be destroyed.

s/id/is/

Quoted 17 lines
hw/xen/xen-bus.c +13 -0
+     */
+    if (xendev->backend_online &&
+        xendev->backend_state == XenbusStateClosed) {
+        xen_device_backend_set_state(xendev, XenbusStateInitWait);
+    } else if (!xendev->backend_online &&
+               (xendev->backend_state == XenbusStateClosed ||
+                xendev->backend_state == XenbusStateInitialising ||
+                xendev->backend_state == XenbusStateInitWait ||
+                xendev->backend_state == XenbusStateUnknown)) {
+        object_unparent(OBJECT(xendev));
+    }
+}
+
 static void xen_device_backend_create(XenDevice *xendev, Error **errp)
 {
     XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev)));

hw/xen/xen-bus.c static void xen_device_backend_create(XenDevice *xendev, Error **errp) · line 464

Quoted 2 lines
hw/xen/xen-bus.c +0 -0
@@ -289,12 +463,38 @@ static void xen_device_backend_create(XenDevice *xendev, Error **errp)
         error_propagate(errp, local_err);
         error_prepend(errp, "failed to create backend: ");

It looks like there is a missing return here.

hw/xen/xen-bus.c static void xen_device_backend_create(XenDevice *xendev, Error **errp) · line 473

Quoted 9 lines
hw/xen/xen-bus.c +8 -0
     }
+
+    xendev->backend_state_watch =
+        xen_bus_add_watch(xenbus, xendev->backend_path,
+                          "state", xen_device_backend_changed,
+                          xendev, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        error_prepend(errp, "failed to watch backend state: ");

You should return here, as local_err mustn't be reused.

hw/xen/xen-bus.c static void xen_device_backend_create(XenDevice *xendev, Error **errp) · line 482

Quoted 9 lines
hw/xen/xen-bus.c +9 -0
+    }
+
+    xendev->backend_online_watch =
+        xen_bus_add_watch(xenbus, xendev->backend_path,
+                          "online", xen_device_backend_changed,
+                          xendev, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        error_prepend(errp, "failed to watch backend online: ");

You probably want a return here, in case there is more code added after.

Review static void xen_device_backend_create(XenDevice *xendev, Error **errp) · line 483

Quoted 1 line
(quoted diff) +1 -0
+    }

Other instances of error_propagate;error_prepend to be replaced by error_propagate_prepend.

Review static void xen_device_backend_create(XenDevice *xendev, Error **errp) · line 485

Quoted 2 lines
(quoted diff) +0 -0
 }
 

Thanks,

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#101 lore raw

Re: [Qemu-devel] [PATCH 15/18] xen: add a mechanism to automatically create XenDevice-s...

Quoted 19 lines

-----Original Message-----
From: Anthony PERARD [mailto:[email protected]]
Sent: 04 December 2018 15:35
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; xen- [email protected]; Stefano Stabellini <[email protected]>
Subject: Re: [PATCH 15/18] xen: add a mechanism to automatically create XenDevice-s...

Quoted 1 line · Paul Durrant

+ xen_backend_device_create(BUS(xenbus), type, name, opts,

&local_err);

hw/xen/xen-bus.c static void xen_bus_remove_watch(XenBus *xenbus, XenWatch *watch)

Quoted 6 lines
hw/xen/xen-bus.c +6 -0
+    qobject_unref(opts);
+
+    if (local_err) {
+        const char *msg = error_get_pretty(local_err);
+
+        error_report("failed to create '%s' device '%s': %s", type,

name,

Quoted 7 lines

hw/xen/xen-bus.c static void xen_bus_remove_watch(XenBus *xenbus, XenWatch *watch) · line 182

Quoted 2 lines
hw/xen/xen-bus.c +2 -0
+                     msg);
+        error_free(local_err);

You can use error_reportf_err() instead of those three calls. I may have only suggest error_report_err in a previous patch, but error_reportf_err does the error_prepend as well.

Ah. I'll go back over the patches and use that where necessary.

Quoted 7 lines

hw/xen/xen-bus.c static void xen_bus_remove_watch(XenBus *xenbus, XenWatch *watch)

Quoted 6 lines
hw/xen/xen-bus.c +6 -0
+    }
+}
+
+static void xen_bus_type_enumerate(XenBus *xenbus, const char *type)
+{
+    char *domain_path = g_strdup_printf("backend/%s/%u", type,

xen_domid);

Quoted 10 lines

hw/xen/xen-bus.c static void xen_bus_remove_watch(XenBus *xenbus, XenWatch *watch) · line 195

Quoted 7 lines
hw/xen/xen-bus.c +7 -0
+    char **backend;
+    unsigned int i, n;
+
+    trace_xen_bus_type_enumerate(type);
+
+    backend = xs_directory(xenbus->xsh, XBT_NULL, domain_path, &n);
+    if (!backend) {

domain_path isn't free here, you probably want a goto out which would free everything.

Ok.

Quoted 16 lines

hw/xen/xen-bus.c static void xen_bus_realize(BusState *bus, Error

Quoted 5 lines
hw/xen/xen-bus.c +3 -0
+        return;
+    }
+
@@ -193,6 +302,17 @@ static void xen_bus_realize(BusState *bus, Error

**errp)

hw/xen/xen-bus.c static void xen_bus_realize(BusState *bus, Error **errp)

Quoted 9 lines
hw/xen/xen-bus.c +6 -0
     notifier_list_init(&xenbus->watch_notifiers);
     qemu_set_fd_handler(xs_fileno(xenbus->xsh), xen_bus_watch, NULL,
                         xenbus);
+
+    module_call_init(MODULE_INIT_XEN_BACKEND);
+
+    xenbus->backend_watch =
+        xen_bus_add_watch(xenbus, "", /* domain root node */
+                          "backend", xen_bus_enumerate, xenbus,

&local_err);

Quoted 8 lines

hw/xen/xen-bus.c static void xen_bus_realize(BusState *bus, Error **errp) · line 313

Quoted 3 lines
hw/xen/xen-bus.c +3 -0
+    if (local_err) {
+        error_propagate(errp, local_err);
+        error_prepend(errp, "failed to set up enumeration watch: ");

You should use error_propagate_prepend instead error_propagate;error_prepend. And it looks like there is the same mistake in other patches that I haven't notice.

Oh, I didn't know about that one either... I've only seen the separate calls used elsewhere.

Quoted 2 lines

Also you probably want goto fail here.

Not sure about that. Whilst the bus scan won't happen, it doesn't mean devices can't be added via QMP.

Quoted 12 lines
Quoted 12 lines
hw/xen/xen-bus.c +11 -0
+static void xen_device_backend_changed(void *opaque)
+{
+    XenDevice *xendev = opaque;
+    const char *type = object_get_typename(OBJECT(xendev));
+    enum xenbus_state state;
+    unsigned int online;
+
+    trace_xen_device_backend_changed(type, xendev->name);
+
+    if (xen_device_backend_scanf(xendev, "state", "%u", &state) != 1) {
+        state = XenbusStateUnknown;
Quoted 8 lines

hw/xen/xen-bus.c enum xenbus_state xen_device_backend_get_state(XenDevice *xendev) · line 418

Quoted 3 lines
hw/xen/xen-bus.c +3 -0
+    }
+
+    xen_device_backend_set_state(xendev, state);

It's kind of weird to set the internal state base on the external one that something else may have modified. Shouldn't we check that it is fine for something else to modify the state and that it is a correct transition?

The only thing (apart from this code) that's going to have perms to write the backend state is the toolstack... which is, of course, be definition trusted.

Quoted 4 lines

Also aren't we going in a loop by having QEMU set the state, then the watch fires again? (Not really a loop since the function _set_state check for changes.

No. It's de-bounced inside the set_state function.

Quoted 4 lines

Also maybe we should watch for the state changes only when something else like libxl creates (ask for) the backend, and ignore changes when QEMU did it itself.

I don't think it's necessary to add that complexity.

Quoted 17 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+
+    if (xen_device_backend_scanf(xendev, "online", "%u", &online) != 1)

{

hw/xen/xen-bus.c enum xenbus_state xen_device_backend_get_state(XenDevice *xendev)

Quoted 11 lines
hw/xen/xen-bus.c +11 -0
+        online = 0;
+    }
+
+    xen_device_backend_set_online(xendev, !!online);
+
+    /*
+     * If a backend is still 'online' then its state should be cycled
+     * back round to InitWait in order for a new frontend instance to
+     * connect. This may happen when, for example, a frontend driver is
+     * re-installed or updated.
+     * If a backend id not 'online' then the device should be

destroyed.

Quoted 1 line

s/id/is/

Ok.

Quoted 46 lines

hw/xen/xen-bus.c static void xen_device_backend_create(XenDevice

Quoted 18 lines
hw/xen/xen-bus.c +13 -0
+     */
+    if (xendev->backend_online &&
+        xendev->backend_state == XenbusStateClosed) {
+        xen_device_backend_set_state(xendev, XenbusStateInitWait);
+    } else if (!xendev->backend_online &&
+               (xendev->backend_state == XenbusStateClosed ||
+                xendev->backend_state == XenbusStateInitialising ||
+                xendev->backend_state == XenbusStateInitWait ||
+                xendev->backend_state == XenbusStateUnknown)) {
+        object_unparent(OBJECT(xendev));
+    }
+}
+
 static void xen_device_backend_create(XenDevice *xendev, Error **errp)
 {
     XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev)));
@@ -289,12 +463,38 @@ static void xen_device_backend_create(XenDevice

*xendev, Error **errp)

hw/xen/xen-bus.c static void xen_device_backend_create(XenDevice *xendev, Error **errp) · line 464

Quoted 2 lines
hw/xen/xen-bus.c +0 -0
         error_propagate(errp, local_err);
         error_prepend(errp, "failed to create backend: ");

It looks like there is a missing return here.

hw/xen/xen-bus.c static void xen_device_backend_create(XenDevice *xendev, Error **errp) · line 473

Quoted 9 lines
hw/xen/xen-bus.c +8 -0
     }
+
+    xendev->backend_state_watch =
+        xen_bus_add_watch(xenbus, xendev->backend_path,
+                          "state", xen_device_backend_changed,
+                          xendev, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        error_prepend(errp, "failed to watch backend state: ");

You should return here, as local_err mustn't be reused.

hw/xen/xen-bus.c static void xen_device_backend_create(XenDevice *xendev, Error **errp) · line 482

Quoted 9 lines
hw/xen/xen-bus.c +9 -0
+    }
+
+    xendev->backend_online_watch =
+        xen_bus_add_watch(xenbus, xendev->backend_path,
+                          "online", xen_device_backend_changed,
+                          xendev, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        error_prepend(errp, "failed to watch backend online: ");
Quoted 1 line

You probably want a return here, in case there is more code added after.

Yes, there should be returns in all three cases above.

Quoted 5 lines

Review static void xen_device_backend_create(XenDevice · line 483

Quoted 2 lines
(quoted diff) +1 -0
+    }

Other instances of error_propagate;error_prepend to be replaced by error_propagate_prepend.

Yes, will do.

Paul

Quoted 8 lines

Review static void xen_device_backend_create(XenDevice · line 485

Quoted 3 lines
(quoted diff) +0 -0
 }
 

Thanks,

--
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#102 lore raw

Re: [PATCH 15/18] xen: add a mechanism to automatically create XenDevice-s...

Quoted 13 lines · Paul Durrant
Quoted 13 lines

-----Original Message-----
From: Anthony PERARD [mailto:[email protected]]
Sent: 04 December 2018 15:35

hw/xen/xen-bus.c static void xen_bus_realize(BusState *bus, Error **errp)

Quoted 3 lines · Paul Durrant
hw/xen/xen-bus.c +3 -0
+    xenbus->backend_watch =
+        xen_bus_add_watch(xenbus, "", /* domain root node */
+                          "backend", xen_bus_enumerate, xenbus,

&local_err);

Quoted 3 lines
hw/xen/xen-bus.c +3 -0
+    if (local_err) {
+        error_propagate(errp, local_err);
+        error_prepend(errp, "failed to set up enumeration watch: ");
Quoted 6 lines
Quoted 4 lines

You should use error_propagate_prepend instead error_propagate;error_prepend. And it looks like there is the same mistake in other patches that I haven't notice.

Oh, I didn't know about that one either... I've only seen the separate calls used elsewhere.

That information is all in "include/qapi/error.h", if you which to know more on how to use Error.

Quoted 4 lines
Quoted 2 lines

Also you probably want goto fail here.

Not sure about that. Whilst the bus scan won't happen, it doesn't mean devices can't be added via QMP.

In that case, don't modify errp, and use error_reportf_err instead, or warn_reportf_err (then local_err = NULL, in case it is reused in a future modification of the function).

Setting errp (with error_propagate) means that the function failed, and QEMU is going to exit(1), because of qdev_init_nofail call in xen_bus_init.

Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
hw/xen/xen-bus.c +11 -0
+static void xen_device_backend_changed(void *opaque)
+{
+    XenDevice *xendev = opaque;
+    const char *type = object_get_typename(OBJECT(xendev));
+    enum xenbus_state state;
+    unsigned int online;
+
+    trace_xen_device_backend_changed(type, xendev->name);
+
+    if (xen_device_backend_scanf(xendev, "state", "%u", &state) != 1) {
+        state = XenbusStateUnknown;
Quoted 8 lines

hw/xen/xen-bus.c enum xenbus_state xen_device_backend_get_state(XenDevice *xendev) · line 418

Quoted 3 lines
hw/xen/xen-bus.c +3 -0
+    }
+
+    xen_device_backend_set_state(xendev, state);

It's kind of weird to set the internal state base on the external one that something else may have modified. Shouldn't we check that it is fine for something else to modify the state and that it is a correct transition?

Quoted 1 line

The only thing (apart from this code) that's going to have perms to write the backend state is the toolstack... which is, of course, be definition trusted.

"trusted" doesn't mean that there isn't a bug somewhere else :-). But I guess it's good enough for now.

Quoted 4 lines
Quoted 3 lines

Also aren't we going in a loop by having QEMU set the state, then the watch fires again? (Not really a loop since the function _set_state check for changes.

Quoted 8 lines

No. It's de-bounced inside the set_state function.

Quoted 4 lines

Also maybe we should watch for the state changes only when something else like libxl creates (ask for) the backend, and ignore changes when QEMU did it itself.

I don't think it's necessary to add that complexity.

Ok.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#103 lore raw

Re: [Qemu-devel] [PATCH 15/18] xen: add a mechanism to automatically create XenDevice-s...

In reply to Paul Durrant
Quoted 13 lines · Paul Durrant
Quoted 13 lines

-----Original Message-----
From: Anthony PERARD [mailto:[email protected]]
Sent: 04 December 2018 15:35

hw/xen/xen-bus.c static void xen_bus_realize(BusState *bus, Error **errp)

Quoted 3 lines · Paul Durrant
hw/xen/xen-bus.c +3 -0
+    xenbus->backend_watch =
+        xen_bus_add_watch(xenbus, "", /* domain root node */
+                          "backend", xen_bus_enumerate, xenbus,

&local_err);

Quoted 3 lines
hw/xen/xen-bus.c +3 -0
+    if (local_err) {
+        error_propagate(errp, local_err);
+        error_prepend(errp, "failed to set up enumeration watch: ");
Quoted 6 lines
Quoted 4 lines

You should use error_propagate_prepend instead error_propagate;error_prepend. And it looks like there is the same mistake in other patches that I haven't notice.

Oh, I didn't know about that one either... I've only seen the separate calls used elsewhere.

That information is all in "include/qapi/error.h", if you which to know more on how to use Error.

Quoted 4 lines
Quoted 2 lines

Also you probably want goto fail here.

Not sure about that. Whilst the bus scan won't happen, it doesn't mean devices can't be added via QMP.

In that case, don't modify errp, and use error_reportf_err instead, or warn_reportf_err (then local_err = NULL, in case it is reused in a future modification of the function).

Setting errp (with error_propagate) means that the function failed, and QEMU is going to exit(1), because of qdev_init_nofail call in xen_bus_init.

Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
hw/xen/xen-bus.c +11 -0
+static void xen_device_backend_changed(void *opaque)
+{
+    XenDevice *xendev = opaque;
+    const char *type = object_get_typename(OBJECT(xendev));
+    enum xenbus_state state;
+    unsigned int online;
+
+    trace_xen_device_backend_changed(type, xendev->name);
+
+    if (xen_device_backend_scanf(xendev, "state", "%u", &state) != 1) {
+        state = XenbusStateUnknown;
Quoted 8 lines

hw/xen/xen-bus.c enum xenbus_state xen_device_backend_get_state(XenDevice *xendev) · line 418

Quoted 3 lines
hw/xen/xen-bus.c +3 -0
+    }
+
+    xen_device_backend_set_state(xendev, state);

It's kind of weird to set the internal state base on the external one that something else may have modified. Shouldn't we check that it is fine for something else to modify the state and that it is a correct transition?

Quoted 1 line

The only thing (apart from this code) that's going to have perms to write the backend state is the toolstack... which is, of course, be definition trusted.

"trusted" doesn't mean that there isn't a bug somewhere else :-). But I guess it's good enough for now.

Quoted 4 lines
Quoted 3 lines

Also aren't we going in a loop by having QEMU set the state, then the watch fires again? (Not really a loop since the function _set_state check for changes.

Quoted 8 lines

No. It's de-bounced inside the set_state function.

Quoted 4 lines

Also maybe we should watch for the state changes only when something else like libxl creates (ask for) the backend, and ignore changes when QEMU did it itself.

I don't think it's necessary to add that complexity.

Ok.

Signature · 1 line
Anthony PERARD
#104 lore raw

Re: [Qemu-devel] [PATCH 15/18] xen: add a mechanism to automatically create XenDevice-s...

Quoted 29 lines

-----Original Message-----
From: Anthony PERARD [mailto:[email protected]]
Sent: 06 December 2018 15:24
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; xen- [email protected]; Stefano Stabellini <[email protected]>
Subject: Re: [PATCH 15/18] xen: add a mechanism to automatically create XenDevice-s...

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Anthony PERARD [mailto:[email protected]]
Sent: 04 December 2018 15:35

Quoted 8 lines
Quoted 8 lines · Paul Durrant

hw/xen/xen-bus.c static void xen_bus_realize(BusState *bus, Error **errp)

Quoted 3 lines
hw/xen/xen-bus.c +3 -0
+    xenbus->backend_watch =
+        xen_bus_add_watch(xenbus, "", /* domain root node */
+                          "backend", xen_bus_enumerate, xenbus,

&local_err);

Quoted 3 lines
hw/xen/xen-bus.c +3 -0
+    if (local_err) {
+        error_propagate(errp, local_err);
+        error_prepend(errp, "failed to set up enumeration watch:

");

Quoted 6 lines
Quoted 5 lines

You should use error_propagate_prepend instead error_propagate;error_prepend. And it looks like there is the same mistake in other patches that I haven't notice.

Quoted 6 lines
Quoted 1 line

Oh, I didn't know about that one either... I've only seen the separate

calls used elsewhere.

That information is all in "include/qapi/error.h", if you which to know more on how to use Error.

Thanks.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Also you probably want goto fail here.

Not sure about that. Whilst the bus scan won't happen, it doesn't mean

devices can't be added via QMP.

Quoted 7 lines

In that case, don't modify errp, and use error_reportf_err instead, or warn_reportf_err (then local_err = NULL, in case it is reused in a future modification of the function).

Setting errp (with error_propagate) means that the function failed, and QEMU is going to exit(1), because of qdev_init_nofail call in xen_bus_init.

Ah, good point. I'll wait for more feedback on v2 and then fix in v3.

Paul

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#105 lore raw

PATCH 16/18 xen: automatically create XenQdiskDevice-s

In reply to Paul Durrant

This patch adds a creator function for XenQdiskDevice-s so that they can be created automatically when the Xen toolstack instantiates a new PV backend. When the XenQdiskDevice is created this way it is also necessary to create a drive which matches the configuration that the Xen toolstack has written into xenstore. This drive is marked 'auto_del' so that it will be removed when the XenQdiskDevice is destroyed. Also, for compatibilitye with the legacy 'xen_disk' implementation, an iothread is automatically created for the new XenQdiskDevice. This will also be removed when he XenQdiskDevice is destroyed.

Correspondingly the legacy backend scan for 'qdisk' is removed.

After this patch is applied the legacy 'xen_disk' code is redundant. It will be removed by a subsequent patch.

---
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

---
 hw/block/trace-events       |   1 +
 hw/block/xen-qdisk.c        | 237 +++++++++++++++++++++++++++++++++++++++++++-
 hw/xen/xen-legacy-backend.c |   1 -
 include/hw/xen/xen-qdisk.h  |   1 +
 4 files changed, 238 insertions(+), 2 deletions(-)
hw/block/trace-events +1 -0
index 8b95567560..ee2ac756cf 100644
@@ -133,3 +133,4 @@ xen_qdisk_realize(uint32_t disk, uint32_t partition) "d%up%u"
 xen_qdisk_connect(uint32_t disk, uint32_t partition) "d%up%u"
 xen_qdisk_disconnect(uint32_t disk, uint32_t partition) "d%up%u"
 xen_qdisk_unrealize(uint32_t disk, uint32_t partition) "d%up%u"
+xen_qdisk_device_create(const char *name) "name: %s"
hw/block/xen-qdisk.c +236 -1

267 lines not on this page · raw message

hw/xen/xen-legacy-backend.c +0 -1
index 2d748665a6..cc0add0a5b 100644
@@ -753,7 +753,6 @@ void xen_be_register_common(void)
 
     xen_be_register("console", &xen_console_ops);
     xen_be_register("vkbd", &xen_kbdmouse_ops);
-    xen_be_register("qdisk", &xen_blkdev_ops);
 #ifdef CONFIG_VIRTFS
     xen_be_register("9pfs", &xen_9pfs_ops);
 #endif
include/hw/xen/xen-qdisk.h +1 -0
index d7dd2bf0ee..c7bc011731 100644
@@ -44,6 +44,7 @@ struct XenQdiskDevice {
     BlockConf conf;
     unsigned int max_ring_page_order;
     IOThread *iothread;
+    IOThread *auto_iothread;
     XenQdiskDataPlane *dataplane;
 };
 
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#106 lore raw

PATCH 16/18 xen: automatically create XenQdiskDevice-s

In reply to Paul Durrant

This patch adds a creator function for XenQdiskDevice-s so that they can be created automatically when the Xen toolstack instantiates a new PV backend. When the XenQdiskDevice is created this way it is also necessary to create a drive which matches the configuration that the Xen toolstack has written into xenstore. This drive is marked 'auto_del' so that it will be removed when the XenQdiskDevice is destroyed. Also, for compatibilitye with the legacy 'xen_disk' implementation, an iothread is automatically created for the new XenQdiskDevice. This will also be removed when he XenQdiskDevice is destroyed.

Correspondingly the legacy backend scan for 'qdisk' is removed.

After this patch is applied the legacy 'xen_disk' code is redundant. It will be removed by a subsequent patch.

---
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

---
 hw/block/trace-events       |   1 +
 hw/block/xen-qdisk.c        | 237 +++++++++++++++++++++++++++++++++++++++++++-
 hw/xen/xen-legacy-backend.c |   1 -
 include/hw/xen/xen-qdisk.h  |   1 +
 4 files changed, 238 insertions(+), 2 deletions(-)
hw/block/trace-events +1 -0
index 8b95567560..ee2ac756cf 100644
@@ -133,3 +133,4 @@ xen_qdisk_realize(uint32_t disk, uint32_t partition) "d%up%u"
 xen_qdisk_connect(uint32_t disk, uint32_t partition) "d%up%u"
 xen_qdisk_disconnect(uint32_t disk, uint32_t partition) "d%up%u"
 xen_qdisk_unrealize(uint32_t disk, uint32_t partition) "d%up%u"
+xen_qdisk_device_create(const char *name) "name: %s"
hw/block/xen-qdisk.c +236 -1

267 lines not on this page · raw message

hw/xen/xen-legacy-backend.c +0 -1
index 2d748665a6..cc0add0a5b 100644
@@ -753,7 +753,6 @@ void xen_be_register_common(void)
 
     xen_be_register("console", &xen_console_ops);
     xen_be_register("vkbd", &xen_kbdmouse_ops);
-    xen_be_register("qdisk", &xen_blkdev_ops);
 #ifdef CONFIG_VIRTFS
     xen_be_register("9pfs", &xen_9pfs_ops);
 #endif
include/hw/xen/xen-qdisk.h +1 -0
index d7dd2bf0ee..c7bc011731 100644
@@ -44,6 +44,7 @@ struct XenQdiskDevice {
     BlockConf conf;
     unsigned int max_ring_page_order;
     IOThread *iothread;
+    IOThread *auto_iothread;
     XenQdiskDataPlane *dataplane;
 };
 
Signature · 1 line
2.11.0
#107 lore raw

Re: [Qemu-devel] [PATCH 16/18] xen: automatically create XenQdiskDevice-s

Quoted 9 lines · Paul Durrant

This patch adds a creator function for XenQdiskDevice-s so that they can be created automatically when the Xen toolstack instantiates a new PV backend. When the XenQdiskDevice is created this way it is also necessary to create a drive which matches the configuration that the Xen toolstack has written into xenstore. This drive is marked 'auto_del' so that it will be removed when the XenQdiskDevice is destroyed. Also, for compatibilitye with the legacy 'xen_disk' implementation, an iothread is automatically created for the new XenQdiskDevice. This will also be removed when he XenQdiskDevice is destroyed.

"the XenQdiskDevice"

[...]

Quoted 1 line

+ qemu_opt_set(drive_opts, "file.locking", "off", &local_err);

That looks new, compared to the xen_disk.c implementation. Maybe that should be mention in the commit message.

[..]

Quoted 3 lines
hw/block/xen-qdisk.c +3 -0
+static void xen_qdisk_device_create(BusState *bus, const char *name,
+                                    QDict *opts, Error **errp)
+{

[...]

Quoted 1 line

+ iothread = iothread_create(vdev, &error_abort);

I would just propagate the error, since iothread could fail for external reason. No need to crash qemu while a VM is running.

Quoted 10 lines
hw/block/xen-qdisk.c +10 -0
+
+    dev = qdev_create(bus, TYPE_XEN_QDISK_DEVICE);
+
+    qdev_prop_set_string(dev, "vdev", vdev);
+
+    if (XEN_QDISK_DEVICE(dev)->vdev.number != number) {
+        error_setg(errp, "invalid dev parameter '%s'", vdev);
+        goto unref;
+    }
+

hw/block/xen-qdisk.c static void xen_qdisk_register_types(void) · line 668

Quoted 10 lines
hw/block/xen-qdisk.c +10 -0
+    qdev_prop_set_drive(dev, "drive", blk, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        error_prepend(errp, "failed to set 'drive': ");
+        goto unref;
+    }
+
+    XEN_QDISK_DEVICE(dev)->auto_iothread = iothread;
+
+    qdev_init_nofail(dev);

That function shouldn't be use during hotplug. But I'm not sure what should be done instead, probably object_property_set_bool(..., true "realized") and check for error.

Thanks,

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#108 lore raw

Re: [PATCH 16/18] xen: automatically create XenQdiskDevice-s

Quoted 20 lines

-----Original Message-----
From: Anthony PERARD [mailto:[email protected]]
Sent: 04 December 2018 16:41
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; xen- [email protected]; Kevin Wolf <[email protected]>; Max Reitz <[email protected]>; Stefano Stabellini <[email protected]>
Subject: Re: [PATCH 16/18] xen: automatically create XenQdiskDevice-s

Quoted 9 lines · Paul Durrant

This patch adds a creator function for XenQdiskDevice-s so that they can be created automatically when the Xen toolstack instantiates a new PV backend. When the XenQdiskDevice is created this way it is also necessary to create a drive which matches the configuration that the Xen toolstack has written into xenstore. This drive is marked 'auto_del' so that it will be removed when the XenQdiskDevice is destroyed. Also, for compatibilitye with the legacy 'xen_disk' implementation, an iothread is automatically created for the new XenQdiskDevice. This will also be removed when he XenQdiskDevice is destroyed.

Quoted 8 lines

"the XenQdiskDevice"

[...]

Quoted 1 line

+ qemu_opt_set(drive_opts, "file.locking", "off", &local_err);

That looks new, compared to the xen_disk.c implementation. Maybe that should be mention in the commit message.

It's necessary to avoid problems when an emulated device is also present. The xen_disk code avoided the issue by basically bypassing the checks and stooging into the middle of the block code. I'll add a comment to the code saying why locking needs to be off.

Quoted 11 lines

[..]

Quoted 3 lines
hw/block/xen-qdisk.c +3 -0
+static void xen_qdisk_device_create(BusState *bus, const char *name,
+                                    QDict *opts, Error **errp)
+{

[...]

Quoted 1 line

+ iothread = iothread_create(vdev, &error_abort);

I would just propagate the error, since iothread could fail for external reason. No need to crash qemu while a VM is running.

True.

Quoted 17 lines
Quoted 17 lines
hw/block/xen-qdisk.c +16 -0
+
+    dev = qdev_create(bus, TYPE_XEN_QDISK_DEVICE);
+
+    qdev_prop_set_string(dev, "vdev", vdev);
+
+    if (XEN_QDISK_DEVICE(dev)->vdev.number != number) {
+        error_setg(errp, "invalid dev parameter '%s'", vdev);
+        goto unref;
+    }
+
+    qdev_prop_set_drive(dev, "drive", blk, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        error_prepend(errp, "failed to set 'drive': ");
+        goto unref;
+    }
Quoted 8 lines

hw/block/xen-qdisk.c static void xen_qdisk_register_types(void) · line 668

Quoted 4 lines
hw/block/xen-qdisk.c +4 -0
+
+    XEN_QDISK_DEVICE(dev)->auto_iothread = iothread;
+
+    qdev_init_nofail(dev);

That function shouldn't be use during hotplug. But I'm not sure what should be done instead, probably object_property_set_bool(..., true "realized") and check for error.

Ok, I'll do that.

Paul

Quoted 6 lines

Thanks,

--
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#109 lore raw

Re: [Qemu-devel] [PATCH 16/18] xen: automatically create XenQdiskDevice-s

In reply to Anthony PERARD
Quoted 20 lines

-----Original Message-----
From: Anthony PERARD [mailto:[email protected]]
Sent: 04 December 2018 16:41
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; xen- [email protected]; Kevin Wolf <[email protected]>; Max Reitz <[email protected]>; Stefano Stabellini <[email protected]>
Subject: Re: [PATCH 16/18] xen: automatically create XenQdiskDevice-s

Quoted 9 lines · Paul Durrant

This patch adds a creator function for XenQdiskDevice-s so that they can be created automatically when the Xen toolstack instantiates a new PV backend. When the XenQdiskDevice is created this way it is also necessary to create a drive which matches the configuration that the Xen toolstack has written into xenstore. This drive is marked 'auto_del' so that it will be removed when the XenQdiskDevice is destroyed. Also, for compatibilitye with the legacy 'xen_disk' implementation, an iothread is automatically created for the new XenQdiskDevice. This will also be removed when he XenQdiskDevice is destroyed.

Quoted 8 lines

"the XenQdiskDevice"

[...]

Quoted 1 line

+ qemu_opt_set(drive_opts, "file.locking", "off", &local_err);

That looks new, compared to the xen_disk.c implementation. Maybe that should be mention in the commit message.

It's necessary to avoid problems when an emulated device is also present. The xen_disk code avoided the issue by basically bypassing the checks and stooging into the middle of the block code. I'll add a comment to the code saying why locking needs to be off.

Quoted 11 lines

[..]

Quoted 3 lines
hw/block/xen-qdisk.c +3 -0
+static void xen_qdisk_device_create(BusState *bus, const char *name,
+                                    QDict *opts, Error **errp)
+{

[...]

Quoted 1 line

+ iothread = iothread_create(vdev, &error_abort);

I would just propagate the error, since iothread could fail for external reason. No need to crash qemu while a VM is running.

True.

Quoted 17 lines
Quoted 17 lines
hw/block/xen-qdisk.c +16 -0
+
+    dev = qdev_create(bus, TYPE_XEN_QDISK_DEVICE);
+
+    qdev_prop_set_string(dev, "vdev", vdev);
+
+    if (XEN_QDISK_DEVICE(dev)->vdev.number != number) {
+        error_setg(errp, "invalid dev parameter '%s'", vdev);
+        goto unref;
+    }
+
+    qdev_prop_set_drive(dev, "drive", blk, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        error_prepend(errp, "failed to set 'drive': ");
+        goto unref;
+    }
Quoted 8 lines

hw/block/xen-qdisk.c static void xen_qdisk_register_types(void) · line 668

Quoted 4 lines
hw/block/xen-qdisk.c +4 -0
+
+    XEN_QDISK_DEVICE(dev)->auto_iothread = iothread;
+
+    qdev_init_nofail(dev);

That function shouldn't be use during hotplug. But I'm not sure what should be done instead, probably object_property_set_bool(..., true "realized") and check for error.

Ok, I'll do that.

Paul

Quoted 6 lines

Thanks,

--
Anthony PERARD

#110 lore raw

PATCH 17/18 MAINTAINERS: add myself as a Xen maintainer

In reply to Paul Durrant

I have made many significant contributions to the Xen code in QEMU, particularly the recent patches introducing a new PV device framework. I intend to make further significant contributions, porting other PV back- ends to the new framework with the intent of eventually removing the legacy code. It therefore seems reasonable that I become a maintiner of the Xen code.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paolo Bonzini <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 5871f035c3..0b668dd205 100644
@@ -382,6 +382,7 @@ Guest CPU Cores (Xen):
 X86
 M: Stefano Stabellini <[email protected]>
 M: Anthony Perard <[email protected]>
+M: Paul Durrant <[email protected]>
 L: [email protected]
 S: Supported
 F: */xen*
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 17/18
#111 lore raw

Re: [PATCH 17/18] MAINTAINERS: add myself as a Xen maintainer

Quoted 8 lines · Paul Durrant

I have made many significant contributions to the Xen code in QEMU, particularly the recent patches introducing a new PV device framework. I intend to make further significant contributions, porting other PV back- ends to the new framework with the intent of eventually removing the legacy code. It therefore seems reasonable that I become a maintiner of the Xen code.

Quoted 23 lines

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paolo Bonzini <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 5871f035c3..0b668dd205 100644
@@ -382,6 +382,7 @@ Guest CPU Cores (Xen):
 X86
 M: Stefano Stabellini <[email protected]>
 M: Anthony Perard <[email protected]>
+M: Paul Durrant <[email protected]>
 L: [email protected]
 S: Supported
 F: */xen*
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v1 17/18
#112 lore raw

Re: [Qemu-devel] [PATCH 17/18] MAINTAINERS: add myself as a Xen maintainer

In reply to Paul Durrant
Quoted 8 lines · Paul Durrant

I have made many significant contributions to the Xen code in QEMU, particularly the recent patches introducing a new PV device framework. I intend to make further significant contributions, porting other PV back- ends to the new framework with the intent of eventually removing the legacy code. It therefore seems reasonable that I become a maintiner of the Xen code.

Quoted 23 lines

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paolo Bonzini <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 5871f035c3..0b668dd205 100644
@@ -382,6 +382,7 @@ Guest CPU Cores (Xen):
 X86
 M: Stefano Stabellini <[email protected]>
 M: Anthony Perard <[email protected]>
+M: Paul Durrant <[email protected]>
 L: [email protected]
 S: Supported
 F: */xen*
Signature · 1 line
2.11.0
#113 lore raw

Re: [Qemu-devel] [PATCH 17/18] MAINTAINERS: add myself as a Xen maintainer

In reply to Paul Durrant
Quoted 5 lines · Paul Durrant

I have made many significant contributions to the Xen code in QEMU, particularly the recent patches introducing a new PV device framework. I intend to make further significant contributions, porting other PV back- ends to the new framework with the intent of eventually removing the legacy code. It therefore seems reasonable that I become a maintiner of

"a maintainer of"

Quoted 24 lines

the Xen code.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paolo Bonzini <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 5871f035c3..0b668dd205 100644
@@ -382,6 +382,7 @@ Guest CPU Cores (Xen):
 X86
 M: Stefano Stabellini <[email protected]>
 M: Anthony Perard <[email protected]>
+M: Paul Durrant <[email protected]>
 L: [email protected]
 S: Supported
 F: */xen*
#114 lore raw

Re: [Qemu-devel] [PATCH 17/18] MAINTAINERS: add myself as a Xen maintainer

Quoted 11 lines

-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]]
Sent: 29 November 2018 14:01
To: Paul Durrant <[email protected]>; [email protected]; qemu- [email protected]; [email protected]
Cc: Anthony Perard <[email protected]>; Paolo Bonzini <[email protected]>; Stefano Stabellini <[email protected]>
Subject: Re: [Qemu-devel] [PATCH 17/18] MAINTAINERS: add myself as a Xen maintainer

On 21/11/18 16:12, Paul Durrant wrote:

Quoted 8 lines
Quoted 3 lines

I have made many significant contributions to the Xen code in QEMU, particularly the recent patches introducing a new PV device framework. I intend to make further significant contributions, porting other PV

back-

Quoted 2 lines

ends to the new framework with the intent of eventually removing the legacy code. It therefore seems reasonable that I become a maintiner of

"a maintainer of"

Yes, of course. I'll correct it in v2.

Paul

Quoted 12 lines
Quoted 12 lines

the Xen code.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paolo Bonzini <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
Quoted 13 lines

MAINTAINERS Guest CPU Cores (Xen): · line 388

Quoted 13 lines
MAINTAINERS +1 -0
index 5871f035c3..0b668dd205 100644
@@ -382,6 +382,7 @@ Guest CPU Cores (Xen):
 X86
 M: Stefano Stabellini <[email protected]>
 M: Anthony Perard <[email protected]>
+M: Paul Durrant <[email protected]>
 L: [email protected]
 S: Supported
 F: */xen*

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#115 lore raw

Re: [Qemu-devel] [PATCH 17/18] MAINTAINERS: add myself as a Xen maintainer

In reply to Philippe Mathieu-Daudé
Quoted 11 lines

-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]]
Sent: 29 November 2018 14:01
To: Paul Durrant <[email protected]>; [email protected]; qemu- [email protected]; [email protected]
Cc: Anthony Perard <[email protected]>; Paolo Bonzini <[email protected]>; Stefano Stabellini <[email protected]>
Subject: Re: [Qemu-devel] [PATCH 17/18] MAINTAINERS: add myself as a Xen maintainer

On 21/11/18 16:12, Paul Durrant wrote:

Quoted 8 lines
Quoted 3 lines

I have made many significant contributions to the Xen code in QEMU, particularly the recent patches introducing a new PV device framework. I intend to make further significant contributions, porting other PV

back-

Quoted 2 lines

ends to the new framework with the intent of eventually removing the legacy code. It therefore seems reasonable that I become a maintiner of

"a maintainer of"

Yes, of course. I'll correct it in v2.

Paul

Quoted 25 lines
Quoted 25 lines

the Xen code.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paolo Bonzini <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 5871f035c3..0b668dd205 100644
@@ -382,6 +382,7 @@ Guest CPU Cores (Xen):
 X86
 M: Stefano Stabellini <[email protected]>
 M: Anthony Perard <[email protected]>
+M: Paul Durrant <[email protected]>
 L: [email protected]
 S: Supported
 F: */xen*
#116 lore raw

Re: [Qemu-devel] [PATCH 17/18] MAINTAINERS: add myself as a Xen maintainer

In reply to Paul Durrant
Quoted 5 lines · Paul Durrant

I have made many significant contributions to the Xen code in QEMU, particularly the recent patches introducing a new PV device framework. I intend to make further significant contributions, porting other PV back- ends to the new framework with the intent of eventually removing the legacy code. It therefore seems reasonable that I become a maintiner of

"a maintainer of"

Quoted 17 lines

the Xen code.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paolo Bonzini <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +0 -0
index 5871f035c3..0b668dd205 100644

MAINTAINERS Guest CPU Cores (Xen): · line 388

Quoted 7 lines
MAINTAINERS +1 -0
@@ -382,6 +382,7 @@ Guest CPU Cores (Xen):
 X86
 M: Stefano Stabellini <[email protected]>
 M: Anthony Perard <[email protected]>
+M: Paul Durrant <[email protected]>
 L: [email protected]
 S: Supported
 F: */xen*

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v1 17/18
#117 lore raw

Re: [Qemu-devel] [PATCH 17/18] MAINTAINERS: add myself as a Xen maintainer

In reply to Paul Durrant
Quoted 8 lines · Paul Durrant

I have made many significant contributions to the Xen code in QEMU, particularly the recent patches introducing a new PV device framework. I intend to make further significant contributions, porting other PV back- ends to the new framework with the intent of eventually removing the legacy code. It therefore seems reasonable that I become a maintiner of the Xen code.

With the typo fixed:

Signature · 1 line
Anthony PERARD
#118 lore raw

PATCH 18/18 xen: remove the legacy 'xen_disk' backend

In reply to Paul Durrant

This backend has now been replaced by the 'xen-qdisk' XenDevice.

---
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>

---
 hw/block/Makefile.objs |    1 -
 hw/block/xen_disk.c    | 1011 ------------------------------------------------
 2 files changed, 1012 deletions(-)
 delete mode 100644 hw/block/xen_disk.c
hw/block/Makefile.objs +0 -1
index bcdd36d318..d9d2f3fde5 100644
@@ -4,7 +4,6 @@ common-obj-$(CONFIG_SSI_M25P80) += m25p80.o
 common-obj-$(CONFIG_NAND) += nand.o
 common-obj-$(CONFIG_PFLASH_CFI01) += pflash_cfi01.o
 common-obj-$(CONFIG_PFLASH_CFI02) += pflash_cfi02.o
-common-obj-$(CONFIG_XEN) += xen_disk.o
 common-obj-$(CONFIG_XEN) += xen-qdisk.o
 common-obj-$(CONFIG_ECC) += ecc.o
 common-obj-$(CONFIG_ONENAND) += onenand.o
hw/block/xen_disk.c deleted +0 -1011

1,011 lines not on this page · raw message

Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel