Message ID | 20160902094354.25935-3-olaf@aepfle.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, 2 Sep 2016, Olaf Hering wrote: > 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 <olaf@aepfle.de> > --- > hw/i386/xen/xen_platform.c | 31 ++++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) > > diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c > index 53be3c7..6faee4c 100644 > --- a/hw/i386/xen/xen_platform.c > +++ b/hw/i386/xen/xen_platform.c > @@ -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; 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?
On Wed, Sep 14, Stefano Stabellini wrote: > 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? 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
On Fri, 2 Sep 2016, Olaf Hering wrote: > 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 <olaf@aepfle.de> > --- > hw/i386/xen/xen_platform.c | 31 ++++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) > > diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c > index 53be3c7..6faee4c 100644 > --- a/hw/i386/xen/xen_platform.c > +++ b/hw/i386/xen/xen_platform.c > @@ -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(); 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 > + 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; >
On Thu, Oct 13, Stefano Stabellini wrote: > On Fri, 2 Sep 2016, Olaf Hering wrote: > > 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. > 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] This is caused by 49137bf6845eaecad51a047fc06dd11c56118460. I will resend. Olaf
diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c index 53be3c7..6faee4c 100644 --- a/hw/i386/xen/xen_platform.c +++ b/hw/i386/xen/xen_platform.c @@ -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;
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 <olaf@aepfle.de> --- hw/i386/xen/xen_platform.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)