Xen HVM unplug changes
PATCH v2 1/2 xen_platform: unplug also SCSI disks
In reply to Olaf HeringUsing 'vdev=sd[a-o]' will create an emulated LSI controller, which can be used by the emulated BIOS to boot from disk. If the HVM domU has also PV driver the disk may appear twice in the guest. To avoid this an unplug of the emulated hardware is needed, similar to what is done for IDE and NIC drivers already.
Since the SCSI controller provides only disks the entire controller can be unplugged at once.
Impact of the change for classic and pvops based guest kernels:
vdev=sda:disk0
before: pvops: disk0=pv xvda + emulated sda
classic: disk0=pv sda + emulated sdq
after: pvops: disk0=pv xvda
classic: disk0=pv sda
vdev=hda:disk0, vdev=sda:disk1
before: pvops: disk0=pv xvda
disk1=emulated sda
classic: disk0=pv hda
disk1=pv sda + emulated sdq
after: pvops: disk0=pv xvda
disk1=not accessible by blkfront, index hda==index sda
classic: disk0=pv hda
disk1=pv sda
vdev=hda:disk0, vdev=sda:disk1, vdev=sdb:disk2
before: pvops: disk0=pv xvda
disk1=emulated sda
disk2=pv xvdb + emulated sdb
classic: disk0=pv hda
disk1=pv sda + emulated sdq
disk2=pv sdb + emulated sdr
after: pvops: disk0=pv xvda
disk1=not accessible by blkfront, index hda==index sda disk2=pv xvdb
classic: disk0=pv hda
disk1=pv sda
disk2=pv sda
--- hw/i386/xen/xen_platform.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/i386/xen/xen_platform.c +4 -0
@@ -114,6 +114,10 @@ static void unplug_disks(PCIBus *b, PCIDevice *d, void *o) PCI_CLASS_STORAGE_IDE && strcmp(d->name, "xen-pci-passthrough") != 0) {pci_piix3_xen_ide_unplug (DEVICE (d)); + } else if (pci_get_word(d->config + PCI_CLASS_DEVICE) == + PCI_CLASS_STORAGE_SCSI + && strcmp(d->name, "xen-pci-passthrough") != 0) { + object_unparent(OBJECT (d)); } }
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
v2 cover Xen HVM unplug changes
Update unplug in Xen HVM guests to cover more cases. Please review.
Olaf
changes in v2:
- fix issues reported by checkpatch
Olaf Hering (2):
xen_platform: unplug also SCSI disks
xen_platform: SUSE xenlinux unplug for emulated PCI
hw/i386/xen/xen_platform.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v2 2/2 xen_platform: SUSE xenlinux unplug for emulated PCI
Implement SUSE specific unplug protocol for emulated PCI devices in PVonHVM guests. Its a simple 'outl(1, (ioaddr + 4));'. This protocol was implemented and used since Xen 3.0.4. It is used in all SUSE/SLES/openSUSE releases up to SLES11SP3 and openSUSE 12.3.
--- hw/i386/xen/xen_platform.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
hw/i386/xen/xen_platform.c +30 -1
@@ -313,13 +313,42 @@ static void xen_platform_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, unsigned int size) {PCIXenPlatformState *s = opaque; +PCIDevice *pci_dev =PCI_DEVICE (s);switch (addr) {case 0 :/* Platform flags */ platform_fixed_ioport_writeb (opaque,0 , (uint32_t )val);break ; +case 4 : +if (val ==1 ) { +/* +* SUSE unplug for Xenlinux +* xen-kmp used this since xen-3.0.4, instead the official protocol +* from xen-3.3+ It did an unconditional "outl(1, (ioaddr + 4));" +* Pre VMDP 1.7 used 4 and 8 depending on how VMDP was configured. +* If VMDP was to control both disk and LAN it would use 4. +* If it controlled just disk or just LAN, it would use 8 below. +*/ +blk_drain_all (); +blk_flush_all (); +pci_unplug_disks (pci_dev->bus); +pci_unplug_nics (pci_dev->bus); + } +break ;case 8 : -log_writeb (s, (uint32_t )val); +switch (val) { +case 1 : +blk_drain_all (); +blk_flush_all (); +pci_unplug_disks (pci_dev->bus); +break ; +case 2 : +pci_unplug_nics (pci_dev->bus); +break ; +default : +log_writeb (s, (uint32_t )val); +break ; + }break ;default :break ;
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v2 1/2 xen_platform: unplug also SCSI disks
In reply to Olaf HeringUsing 'vdev=sd[a-o]' will create an emulated LSI controller, which can be used by the emulated BIOS to boot from disk. If the HVM domU has also PV driver the disk may appear twice in the guest. To avoid this an unplug of the emulated hardware is needed, similar to what is done for IDE and NIC drivers already.
Since the SCSI controller provides only disks the entire controller can be unplugged at once.
Impact of the change for classic and pvops based guest kernels:
vdev=sda:disk0
before: pvops: disk0=pv xvda + emulated sda
classic: disk0=pv sda + emulated sdq
after: pvops: disk0=pv xvda
classic: disk0=pv sda
vdev=hda:disk0, vdev=sda:disk1
before: pvops: disk0=pv xvda
disk1=emulated sda
classic: disk0=pv hda
disk1=pv sda + emulated sdq
after: pvops: disk0=pv xvda
disk1=not accessible by blkfront, index hda==index sda
classic: disk0=pv hda
disk1=pv sda
vdev=hda:disk0, vdev=sda:disk1, vdev=sdb:disk2
before: pvops: disk0=pv xvda
disk1=emulated sda
disk2=pv xvdb + emulated sdb
classic: disk0=pv hda
disk1=pv sda + emulated sdq
disk2=pv sdb + emulated sdr
after: pvops: disk0=pv xvda
disk1=not accessible by blkfront, index hda==index sda disk2=pv xvdb
classic: disk0=pv hda
disk1=pv sda
disk2=pv sda
--- hw/i386/xen/xen_platform.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/i386/xen/xen_platform.c +4 -0
@@ -114,6 +114,10 @@ static void unplug_disks(PCIBus *b, PCIDevice *d, void *o) PCI_CLASS_STORAGE_IDE && strcmp(d->name, "xen-pci-passthrough") != 0) {pci_piix3_xen_ide_unplug (DEVICE (d)); + } else if (pci_get_word(d->config + PCI_CLASS_DEVICE) == + PCI_CLASS_STORAGE_SCSI + && strcmp(d->name, "xen-pci-passthrough") != 0) { + object_unparent(OBJECT (d)); } }
Re: [Qemu-devel] [PATCH v2 1/2] xen_platform: unplug also SCSI disks
Quoted 51 lines · Olaf Hering
Using 'vdev=sd[a-o]' will create an emulated LSI controller, which can be used by the emulated BIOS to boot from disk. If the HVM domU has also PV driver the disk may appear twice in the guest. To avoid this an unplug of the emulated hardware is needed, similar to what is done for IDE and NIC drivers already.
Since the SCSI controller provides only disks the entire controller can be unplugged at once.
Impact of the change for classic and pvops based guest kernels:
vdev=sda:disk0
before: pvops: disk0=pv xvda + emulated sda
classic: disk0=pv sda + emulated sdq
after: pvops: disk0=pv xvda
classic: disk0=pv sdavdev=hda:disk0, vdev=sda:disk1
before: pvops: disk0=pv xvda
disk1=emulated sda
classic: disk0=pv hda
disk1=pv sda + emulated sdq
after: pvops: disk0=pv xvda
disk1=not accessible by blkfront, index hda==index sda
classic: disk0=pv hda
disk1=pv sdavdev=hda:disk0, vdev=sda:disk1, vdev=sdb:disk2
before: pvops: disk0=pv xvda
disk1=emulated sda
disk2=pv xvdb + emulated sdb
classic: disk0=pv hda
disk1=pv sda + emulated sdq
disk2=pv sdb + emulated sdr
after: pvops: disk0=pv xvda
disk1=not accessible by blkfront, index hda==index sda disk2=pv xvdb
classic: disk0=pv hda
disk1=pv sda
disk2=pv sdaSigned-off-by Olaf Hering <[email protected]>--- hw/i386/xen/xen_platform.c | 4 ++++ 1 file changed, 4 insertions(+)hw/i386/xen/xen_platform.c +0
-0
hw/i386/xen/xen_platform.c static void unplug_disks(PCIBus *b, PCIDevice *d, void *o) · line 122
Quoted 9 lines
hw/i386/xen/xen_platform.c +4
-0@@ -114,6 +114,10 @@ static void unplug_disks(PCIBus *b, PCIDevice *d, void *o) PCI_CLASS_STORAGE_IDE && strcmp(d->name, "xen-pci-passthrough") != 0) {pci_piix3_xen_ide_unplug (DEVICE (d)); + } else if (pci_get_word(d->config + PCI_CLASS_DEVICE) == + PCI_CLASS_STORAGE_SCSI + && strcmp(d->name, "xen-pci-passthrough") != 0) { + object_unparent(OBJECT (d)); } }
Written like this, the code will unplug any Xen SCSI disks together with Xen IDE disks when the guest writes "1" to ioport 0x10. I am sorry to be pedantic, but the recent changes introduced to docs/misc/hvm-emulated-unplug.markdown do not cover any changes in behavior to the existing ioport address (I am looking specifically at point 6). Sorry to only notice this now.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v2 2/2] xen_platform: SUSE xenlinux unplug for emulated PCI
In reply to Olaf HeringQuoted 45 lines · Olaf Hering
Implement SUSE specific unplug protocol for emulated PCI devices in PVonHVM guests. Its a simple '
outl(1, (ioaddr + 4));'. This protocol was implemented and used since Xen 3.0.4. It is used in all SUSE/SLES/openSUSE releases up to SLES11SP3 and openSUSE 12.3.Signed-off-by Olaf Hering <[email protected]>--- hw/i386/xen/xen_platform.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)hw/i386/xen/xen_platform.c +19
-1@@ -313,13 +313,42 @@ static void xen_platform_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, unsigned int size) {PCIXenPlatformState *s = opaque; +PCIDevice *pci_dev =PCI_DEVICE (s);switch (addr) {case 0 :/* Platform flags */ platform_fixed_ioport_writeb (opaque,0 , (uint32_t )val);break ; +case 4 : +if (val ==1 ) { +/* +* SUSE unplug for Xenlinux +* xen-kmp used this since xen-3.0.4, instead the official protocol +* from xen-3.3+ It did an unconditional "outl(1, (ioaddr + 4));" +* Pre VMDP 1.7 used 4 and 8 depending on how VMDP was configured. +* If VMDP was to control both disk and LAN it would use 4. +* If it controlled just disk or just LAN, it would use 8 below. +*/ +blk_drain_all (); +blk_flush_all (); +pci_unplug_disks (pci_dev->bus); +pci_unplug_nics (pci_dev->bus); + } +break ;case 8 : -log_writeb (s, (uint32_t )val); +switch (val) { +case 1 :
hw/i386/xen/xen_platform.c static void xen_platform_ioport_writeb(void *opaque, hwaddr addr, · line 350
Quoted 10 lines
hw/i386/xen/xen_platform.c +10
-0+blk_drain_all (); +blk_flush_all (); +pci_unplug_disks (pci_dev->bus); +break ; +case 2 : +pci_unplug_nics (pci_dev->bus); +break ; +default : +log_writeb (s, (uint32_t )val); +break ;
The doc says:
"If VMDP was configured to control just NIC devices it would write the value 0x1 to offset 0x8. If VMDP was configured to control just storage devices it would write the value 0x2 to offset 0x8."
So 0x1 to 0x8 to unplug NICs, otherwise 0x2 to 0x8 to unplug storage. The switch above does the opposite. What am I missing? Am I misreading the document?
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 1/2] xen_platform: unplug also SCSI disks
In reply to Stefano StabelliniQuoted 6 lines · Stefano Stabellini
Written like this, the code will unplug any Xen SCSI disks together with Xen IDE disks when the guest writes "1" to ioport
0x10. I am sorry to be pedantic, but the recent changes introduced to docs/misc/hvm-emulated-unplug.markdown do not cover any changes in behavior to the existing ioport address (I am looking specifically at point 6). Sorry to only notice this now.
I will update the docs once the code is changed.
Olaf
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v2 1/2] xen_platform: unplug also SCSI disks
In reply to Stefano StabelliniQuoted 6 lines · Stefano Stabellini
Written like this, the code will unplug any Xen SCSI disks together with Xen IDE disks when the guest writes "1" to ioport
0x10. I am sorry to be pedantic, but the recent changes introduced to docs/misc/hvm-emulated-unplug.markdown do not cover any changes in behavior to the existing ioport address (I am looking specifically at point 6). Sorry to only notice this now.
I will update the docs once the code is changed.
Olaf
Re: [PATCH v2 2/2] xen_platform: SUSE xenlinux unplug for emulated PCI
In reply to Stefano StabelliniQuoted 9 lines · Stefano Stabellini
The doc says:
"If VMDP was configured to control just NIC devices it would write the value
0x1to offset0x8. If VMDP was configured to control just storage devices it would write the value0x2to offset0x8."So
0x1to0x8to unplug NICs, otherwise0x2to0x8to unplug storage. The switch above does the opposite. What am I missing? Am I misreading the document?
The doc is wrong, this is what qemu-trad does:
+ case 8:
+ if (val ==1 ) {
+ fprintf(logfile, "Disconnect IDE hard disk...\n");
+ ide_unplug_harddisks();
+ fprintf(logfile, "Done.\n");
+ } else if (val == 2) {
+ fprintf(logfile, "Disconnect netifs...\n");
+ pci_unplug_netifs();
+ fprintf(logfile, "Shutdown taps...\n");
+ net_tap_shutdown_all();
+ fprintf(logfile, "Done.\n");+ }
+ break;
Olaf
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v2 2/2] xen_platform: SUSE xenlinux unplug for emulated PCI
In reply to Stefano StabelliniQuoted 9 lines · Stefano Stabellini
The doc says:
"If VMDP was configured to control just NIC devices it would write the value
0x1to offset0x8. If VMDP was configured to control just storage devices it would write the value0x2to offset0x8."So
0x1to0x8to unplug NICs, otherwise0x2to0x8to unplug storage. The switch above does the opposite. What am I missing? Am I misreading the document?
The doc is wrong, this is what qemu-trad does:
+ case 8:
+ if (val ==1 ) {
+ fprintf(logfile, "Disconnect IDE hard disk...\n");
+ ide_unplug_harddisks();
+ fprintf(logfile, "Done.\n");
+ } else if (val == 2) {
+ fprintf(logfile, "Disconnect netifs...\n");
+ pci_unplug_netifs();
+ fprintf(logfile, "Shutdown taps...\n");
+ net_tap_shutdown_all();
+ fprintf(logfile, "Done.\n");+ }
+ break;
Olaf
Re: [PATCH v2 2/2] xen_platform: SUSE xenlinux unplug for emulated PCI
In reply to Olaf HeringQuoted 27 lines · Olaf Hering
Implement SUSE specific unplug protocol for emulated PCI devices in PVonHVM guests. Its a simple '
outl(1, (ioaddr + 4));'. This protocol was implemented and used since Xen 3.0.4. It is used in all SUSE/SLES/openSUSE releases up to SLES11SP3 and openSUSE 12.3.Signed-off-by Olaf Hering <[email protected]>--- hw/i386/xen/xen_platform.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)hw/i386/xen/xen_platform.c +3
-0@@ -313,13 +313,42 @@ static void xen_platform_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, unsigned int size) {PCIXenPlatformState *s = opaque; +PCIDevice *pci_dev =PCI_DEVICE (s);switch (addr) {case 0 :/* Platform flags */ platform_fixed_ioport_writeb (opaque,0 , (uint32_t )val);break ; +case 4 : +if (val ==1 ) {
hw/i386/xen/xen_platform.c static void xen_platform_ioport_writeb(void *opaque, hwaddr addr, · line 333
Quoted 10 lines
hw/i386/xen/xen_platform.c +10
-0+/* +* SUSE unplug for Xenlinux +* xen-kmp used this since xen-3.0.4, instead the official protocol +* from xen-3.3+ It did an unconditional "outl(1, (ioaddr + 4));" +* Pre VMDP 1.7 used 4 and 8 depending on how VMDP was configured. +* If VMDP was to control both disk and LAN it would use 4. +* If it controlled just disk or just LAN, it would use 8 below. +*/ +blk_drain_all (); +blk_flush_all ();
I was about to send a pull request for this series but blk_flush_all causes a build failure:
/local/qemu-upstream/hw/i386/xen/xen_platform.c: In function 'xen_platform_ioport_writeb':
/local/qemu-upstream/hw/i386/xen/xen_platform.c:331:13: error: implicit declaration of function 'blk_flush_all' [-Werror=implicit-function-declaration] /local/qemu-upstream/hw/i386/xen/xen_platform.c:331:13: error: nested extern declaration of 'blk_flush_all' [-Werror=nested-externs]
cc1: all warnings being treated as errors
make[1]: *** [hw/i386/xen/xen_platform.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [subdir-i386-softmmu] Error 2
Quoted 13 lines
hw/i386/xen/xen_platform.c +10
-1+pci_unplug_disks (pci_dev->bus); +pci_unplug_nics (pci_dev->bus); + } +break ;case 8 : -log_writeb (s, (uint32_t )val); +switch (val) { +case 1 : +blk_drain_all (); +blk_flush_all (); +pci_unplug_disks (pci_dev->bus); +break ;
hw/i386/xen/xen_platform.c static void xen_platform_ioport_writeb(void *opaque, hwaddr addr, · line 354
Quoted 10 lines
hw/i386/xen/xen_platform.c +7
-0+case 2 : +pci_unplug_nics (pci_dev->bus); +break ; +default : +log_writeb (s, (uint32_t )val); +break ; + }break ;default :break ;
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v2 2/2] xen_platform: SUSE xenlinux unplug for emulated PCI
In reply to Olaf HeringQuoted 27 lines · Olaf Hering
Implement SUSE specific unplug protocol for emulated PCI devices in PVonHVM guests. Its a simple '
outl(1, (ioaddr + 4));'. This protocol was implemented and used since Xen 3.0.4. It is used in all SUSE/SLES/openSUSE releases up to SLES11SP3 and openSUSE 12.3.Signed-off-by Olaf Hering <[email protected]>--- hw/i386/xen/xen_platform.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)hw/i386/xen/xen_platform.c +3
-0@@ -313,13 +313,42 @@ static void xen_platform_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, unsigned int size) {PCIXenPlatformState *s = opaque; +PCIDevice *pci_dev =PCI_DEVICE (s);switch (addr) {case 0 :/* Platform flags */ platform_fixed_ioport_writeb (opaque,0 , (uint32_t )val);break ; +case 4 : +if (val ==1 ) {
hw/i386/xen/xen_platform.c static void xen_platform_ioport_writeb(void *opaque, hwaddr addr, · line 333
Quoted 10 lines
hw/i386/xen/xen_platform.c +10
-0+/* +* SUSE unplug for Xenlinux +* xen-kmp used this since xen-3.0.4, instead the official protocol +* from xen-3.3+ It did an unconditional "outl(1, (ioaddr + 4));" +* Pre VMDP 1.7 used 4 and 8 depending on how VMDP was configured. +* If VMDP was to control both disk and LAN it would use 4. +* If it controlled just disk or just LAN, it would use 8 below. +*/ +blk_drain_all (); +blk_flush_all ();
I was about to send a pull request for this series but blk_flush_all causes a build failure:
/local/qemu-upstream/hw/i386/xen/xen_platform.c: In function 'xen_platform_ioport_writeb':
/local/qemu-upstream/hw/i386/xen/xen_platform.c:331:13: error: implicit declaration of function 'blk_flush_all' [-Werror=implicit-function-declaration] /local/qemu-upstream/hw/i386/xen/xen_platform.c:331:13: error: nested extern declaration of 'blk_flush_all' [-Werror=nested-externs]
cc1: all warnings being treated as errors
make[1]: *** [hw/i386/xen/xen_platform.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [subdir-i386-softmmu] Error 2
Quoted 23 lines
hw/i386/xen/xen_platform.c +17
-1+pci_unplug_disks (pci_dev->bus); +pci_unplug_nics (pci_dev->bus); + } +break ;case 8 : -log_writeb (s, (uint32_t )val); +switch (val) { +case 1 : +blk_drain_all (); +blk_flush_all (); +pci_unplug_disks (pci_dev->bus); +break ; +case 2 : +pci_unplug_nics (pci_dev->bus); +break ; +default : +log_writeb (s, (uint32_t )val); +break ; + }break ;default :break ;
Re: [Qemu-devel] [PATCH v2 2/2] xen_platform: SUSE xenlinux unplug for emulated PCI
Quoted 7 lines · Stefano Stabellini
Quoted 5 lines · Olaf Hering
Implement SUSE specific unplug protocol for emulated PCI devices in PVonHVM guests. Its a simple '
outl(1, (ioaddr + 4));'. This protocol was implemented and used since Xen 3.0.4. It is used in all SUSE/SLES/openSUSE releases up to SLES11SP3 and openSUSE 12.3.
Quoted 5 lines
I was about to send a pull request for this series but
blk_flush_allcauses a build failure:/local/qemu-upstream/hw/i386/xen/xen_platform.c: In function '
xen_platform_ioport_writeb':
/local/qemu-upstream/hw/i386/xen/xen_platform.c:331:13: error: implicit declaration of function 'blk_flush_all' [-Werror=implicit-function-declaration]
This is caused by 49137bf6845eaecad51a047fc06dd11c56118460. I will resend.
Olaf