add hotplug opt-out option for pci devices.
cover add hotplug opt-out option for pci devices.
Hi,
This patch series adds a flag which allows pci devices being tagged as not hotpluggable. It also sets this flag for a number of devices.
cheers,
Gerd
Gerd Hoffmann (3):
pci: allow devices being tagged as not hotpluggable.
piix: tag as not hotpluggable.
vga: tag as not hotplugable.
hw/acpi_piix4.c | 2 ++ hw/cirrus_vga.c | 1 + hw/ide/piix.c | 2 ++ hw/pci.c | 10 ++++++++++ hw/pci.h | 3 +++ hw/piix4.c | 1 + hw/piix_pci.c | 2 ++ hw/vga-pci.c | 1 + hw/vmware_vga.c | 1 + qerror.c | 4 ++++ qerror.h | 3 +++ 11 files changed, 30 insertions(+), 0 deletions(-)
PATCH 1/3 pci: allow devices being tagged as not hotpluggable.
This patch adds a field to PCIDeviceInfo to tag devices as being not hotpluggable. Any attempt to plug-in or -out such a device will throw an error.
--- hw/pci.c | 10 ++++++++++ hw/pci.h | 3 +++ qerror.c | 4 ++++ qerror.h | 3 +++ 4 files changed, 20 insertions(+), 0 deletions(-)
hw/pci.c +10 -0
@@ -1546,6 +1546,11 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) info->is_bridge);if (pci_dev ==NULL )return -1 ; +if (qdev->hotplugged && info->no_hotplug) { +qerror_report (QERR_DEVICE_NO_HOTPLUG , info->qdev.name); +do_pci_unregister_device (pci_dev); +return -1 ; + } rc = info->init (pci_dev);if (rc !=0 ) {do_pci_unregister_device (pci_dev);
@@ -1575,7 +1580,12 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)static int pci_unplug_device (DeviceState *qdev) {PCIDevice *dev =DO_UPCAST (PCIDevice, qdev, qdev); +PCIDeviceInfo *info =container_of (qdev->info, PCIDeviceInfo, qdev); +if (info->no_hotplug) { +qerror_report (QERR_DEVICE_NO_HOTPLUG , info->qdev.name); +return -1 ; + }return dev->bus->hotplug (dev->bus->hotplug_qdev, dev,PCI_HOTPLUG_DISABLED ); }
hw/pci.h +3 -0
@@ -431,6 +431,9 @@ typedef struct {/* pcie stuff */ int is_express;/* is this device pci express? */ +/* device isn't hot-pluggable */ +int no_hotplug; +/* rom bar */ const char *romfile; } PCIDeviceInfo;
qerror.c +4 -0
@@ -101,6 +101,10 @@ static const QErrorStringTable qerror_table[] = { .desc = "Device '%(device)' has no child bus", }, { + .error_fmt = QERR_DEVICE_NO_HOTPLUG, + .desc = "Device '%(device)' does not support hotplugging", + }, + { .error_fmt = QERR_DUPLICATE_ID, .desc = "Duplicate ID '%(id)' for %(object)", },
qerror.h +3 -0
@@ -90,6 +90,9 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_DEVICE_NO_BUS \ "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }" +#define QERR_DEVICE_NO_HOTPLUG \ + "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }" +#define QERR_DUPLICATE_ID \ "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
Signature · 1 line
1.7.1
[Qemu-devel] Re: [PATCH 1/3] pci: allow devices being tagged as not hotpluggable.
Quoted 5 lines · Gerd Hoffmann
This patch adds a field to PCIDeviceInfo to tag devices as being not hotpluggable. Any attempt to plug-in or -out such a device will throw an error.
Signed-off-by Gerd Hoffmann <[email protected]>
Quoted 82 lines
--- hw/pci.c | 10 ++++++++++ hw/pci.h | 3 +++ qerror.c | 4 ++++ qerror.h | 3 +++ 4 files changed, 20 insertions(+), 0 deletions(-)hw/pci.c +10
-0@@ -1546,6 +1546,11 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) info->is_bridge);if (pci_dev ==NULL )return -1 ; +if (qdev->hotplugged && info->no_hotplug) { +qerror_report (QERR_DEVICE_NO_HOTPLUG , info->qdev.name); +do_pci_unregister_device (pci_dev); +return -1 ; + } rc = info->init (pci_dev);if (rc !=0 ) {do_pci_unregister_device (pci_dev);@@ -1575,7 +1580,12 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)static int pci_unplug_device (DeviceState *qdev) {PCIDevice *dev =DO_UPCAST (PCIDevice, qdev, qdev); +PCIDeviceInfo *info =container_of (qdev->info, PCIDeviceInfo, qdev); +if (info->no_hotplug) { +qerror_report (QERR_DEVICE_NO_HOTPLUG , info->qdev.name); +return -1 ; + }return dev->bus->hotplug (dev->bus->hotplug_qdev, dev,PCI_HOTPLUG_DISABLED ); }hw/pci.h +3
-0@@ -431,6 +431,9 @@ typedef struct {/* pcie stuff */ int is_express;/* is this device pci express? */ +/* device isn't hot-pluggable */ +int no_hotplug; +/* rom bar */ const char *romfile; } PCIDeviceInfo;qerror.c +4
-0@@ -101,6 +101,10 @@ static const QErrorStringTable qerror_table[] = { .desc = "Device '%(device)' has no child bus", }, { + .error_fmt = QERR_DEVICE_NO_HOTPLUG, + .desc = "Device '%(device)' does not support hotplugging", + }, + { .error_fmt = QERR_DUPLICATE_ID, .desc = "Duplicate ID '%(id)' for %(object)", },qerror.h +3
-0@@ -90,6 +90,9 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_DEVICE_NO_BUS \ "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }" +#define QERR_DEVICE_NO_HOTPLUG \ + "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }" +#define QERR_DUPLICATE_ID \ "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"Signature · 1 line
1.7.1
PATCH 2/3 piix: tag as not hotpluggable.
In reply to Gerd HoffmannThis patch tags all pci devices which belong to the piix3/4 chipsets as not hotpluggable (Host bridge, ISA bridge, IDE controller, ACPI bridge).
--- hw/acpi_piix4.c | 2 ++ hw/ide/piix.c | 2 ++ hw/piix4.c | 1 + hw/piix_pci.c | 2 ++ 4 files changed, 7 insertions(+), 0 deletions(-)
hw/acpi_piix4.c +2 -0
@@ -428,6 +428,8 @@ static PCIDeviceInfo piix4_pm_info = { .qdev.desc = "PM", .qdev.size = sizeof(PIIX4PMState), .qdev.vmsd = &vmstate_acpi, + .qdev.no_user = 1, + .no_hotplug = 1, .init = piix4_pm_initfn, .config_write = pm_write_config, .qdev.props = (Property []) {
hw/ide/piix.c +2 -0
@@ -184,11 +184,13 @@ static PCIDeviceInfo piix_ide_info[] = { .qdev.name = "piix3-ide", .qdev.size = sizeof(PCIIDEState), .qdev.no_user = 1, + .no_hotplug = 1, .init = pci_piix3_ide_initfn, },{ .qdev.name = "piix4-ide", .qdev.size = sizeof(PCIIDEState), .qdev.no_user = 1, + .no_hotplug = 1, .init = pci_piix4_ide_initfn, },{/* end of list */
hw/piix4.c +1 -0
@@ -113,6 +113,7 @@ static PCIDeviceInfo piix4_info[] = { .qdev.desc = "ISA bridge", .qdev.size = sizeof(PCIDevice), .qdev.no_user = 1, + .qdev.no_hotplug = 1, .init = piix4_initfn, },{/* end of list */
hw/piix_pci.c +2 -0
@@ -348,6 +348,7 @@ static PCIDeviceInfo i440fx_info[] = { .qdev.size = sizeof(PCII440FXState), .qdev.vmsd = &vmstate_i440fx, .qdev.no_user = 1, + .no_hotplug = 1, .init = i440fx_initfn, .config_write = i440fx_write_config, },{
@@ -356,6 +357,7 @@ static PCIDeviceInfo i440fx_info[] = { .qdev.size = sizeof(PIIX3State), .qdev.vmsd = &vmstate_piix3, .qdev.no_user = 1, + .no_hotplug = 1, .init = piix3_initfn, },{/* end of list */
Signature · 1 line
1.7.1
[Qemu-devel] Re: [PATCH 2/3] piix: tag as not hotpluggable.
Quoted 47 lines · Gerd Hoffmann
This patch tags all pci devices which belong to the piix3/4 chipsets as not hotpluggable (Host bridge, ISA bridge, IDE controller, ACPI bridge).
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/acpi_piix4.c | 2 ++ hw/ide/piix.c | 2 ++ hw/piix4.c | 1 + hw/piix_pci.c | 2 ++ 4 files changed, 7 insertions(+), 0 deletions(-)hw/acpi_piix4.c +2
-0@@ -428,6 +428,8 @@ static PCIDeviceInfo piix4_pm_info = { .qdev.desc = "PM", .qdev.size = sizeof(PIIX4PMState), .qdev.vmsd = &vmstate_acpi, + .qdev.no_user = 1, + .no_hotplug = 1, .init = piix4_pm_initfn, .config_write = pm_write_config, .qdev.props = (Property []) {hw/ide/piix.c +2
-0@@ -184,11 +184,13 @@ static PCIDeviceInfo piix_ide_info[] = { .qdev.name = "piix3-ide", .qdev.size = sizeof(PCIIDEState), .qdev.no_user = 1, + .no_hotplug = 1, .init = pci_piix3_ide_initfn, },{ .qdev.name = "piix4-ide", .qdev.size = sizeof(PCIIDEState), .qdev.no_user = 1, + .no_hotplug = 1, .init = pci_piix4_ide_initfn, },{/* end of list */ hw/piix4.c +0
-0
hw/piix4.c static PCIDeviceInfo piix4_info[] = { · line 119
Quoted 7 lines
hw/piix4.c +1
-0@@ -113,6 +113,7 @@ static PCIDeviceInfo piix4_info[] = { .qdev.desc = "ISA bridge", .qdev.size = sizeof(PCIDevice), .qdev.no_user = 1, + .qdev.no_hotplug = 1, .init = piix4_initfn, },{/* end of list */
This one breaks the build for me. The below seems to help - but begs the question: was this tested?
Thanks,
hw/piix4.c +1 -1
@@ -113,7 +113,7 @@ static PCIDeviceInfo piix4_info[] = { .qdev.desc = "ISA bridge", .qdev.size = sizeof(PCIDevice), .qdev.no_user = 1, - .qdev.no_hotplug = 1, + .no_hotplug = 1, .init = piix4_initfn, },{/* end of list */
[Qemu-devel] Re: [PATCH 2/3] piix: tag as not hotpluggable.
Quoted 7 lines
Quoted 7 lines
hw/piix4.c +0
-0@@ -113,6 +113,7 @@ static PCIDeviceInfo piix4_info[] = { .qdev.desc = "ISA bridge", .qdev.size = sizeof(PCIDevice),
Quoted 8 lines
hw/piix4.c static PCIDeviceInfo piix4_info[] = { · line 119
Quoted 5 lines
hw/piix4.c +1
-0.qdev.no_user = 1, + .qdev.no_hotplug = 1, .init = piix4_initfn, },{/* end of list */ This one breaks the build for me. The below seems to help - but begs the question: was this tested?
Tested on x86. piix4 chipset is used by hw/mips_malta.c, looks like I forgot to do a testbuild with all targets enabled :-(
hw/piix4.c static PCIDeviceInfo piix4_info[] = { · line 119
Quoted 13 lines
hw/piix4.c +1
-1@@ -113,7 +113,7 @@ static PCIDeviceInfo piix4_info[] = { .qdev.desc = "ISA bridge", .qdev.size = sizeof(PCIDevice), .qdev.no_user = 1, - .qdev.no_hotplug = 1, + .no_hotplug = 1, .init = piix4_initfn, },{/* end of list */
This is correct. Do you just squash in the fix or do you want me respin the patch series?
cheers,
Gerd
[Qemu-devel] Re: [PATCH 2/3] piix: tag as not hotpluggable.
Quoted 16 lines · Gerd Hoffmann
Quoted 7 lines
Quoted 7 lines
hw/piix4.c +0
-0@@ -113,6 +113,7 @@ static PCIDeviceInfo piix4_info[] = { .qdev.desc = "ISA bridge", .qdev.size = sizeof(PCIDevice),Quoted 8 lines
hw/piix4.c static PCIDeviceInfo piix4_info[] = { · line 119
Quoted 5 lines
hw/piix4.c +1
-0.qdev.no_user = 1, + .qdev.no_hotplug = 1, .init = piix4_initfn, },{/* end of list */ This one breaks the build for me. The below seems to help - but begs the question: was this tested?
Quoted 2 lines
Tested on x86. piix4 chipset is used by
hw/mips_malta.c, looks like I forgot to do a testbuild with all targets enabled :-(
Let's just patch whatever was tested for now?
Quoted 17 lines
hw/piix4.c static PCIDeviceInfo piix4_info[] = { · line 119
Quoted 13 lines
hw/piix4.c +1
-1@@ -113,7 +113,7 @@ static PCIDeviceInfo piix4_info[] = { .qdev.desc = "ISA bridge", .qdev.size = sizeof(PCIDevice), .qdev.no_user = 1, - .qdev.no_hotplug = 1, + .no_hotplug = 1, .init = piix4_initfn, },{/* end of list */ This is correct. Do you just squash in the fix or do you want me respin the patch series?
Quoted 2 lines
cheers,
Gerd
Could you split the tested and untested parts to separate patches, noting the status in the commit message?
We could then queue the tested parts directly and wait for maintainer's ack for the rest.
Signature · 1 line
MST
[Qemu-devel] Re: [PATCH 2/3] piix: tag as not hotpluggable.
Hi,
Quoted 2 lines
Could you split the tested and untested parts to separate patches, noting the status in the commit message?
I think this is overkill given how simple the change is. Respin goes to the list shortly.
cheers,
Gerd
[Qemu-devel] Re: [PATCH 2/3] piix: tag as not hotpluggable.
Quoted 6 lines · Gerd Hoffmann
Hi,
Quoted 2 lines
Could you split the tested and untested parts to separate patches, noting the status in the commit message?
I think this is overkill given how simple the change is.
Yes but I don't know whether the untested devices this patch touches are intended to be non hotpluggable. I guess, I'll just ack the pci.c part and let Anthony deal with this.
Quoted 5 lines
Respin
goes to the list shortly.cheers,
Gerd
Re: [Qemu-devel] Re: [PATCH 2/3] piix: tag as not hotpluggable.
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Gerd Hoffmann
Hi,
Quoted 2 lines
Could you split the tested and untested parts to separate patches, noting the status in the commit message?
Quoted 6 lines
Quoted 1 line
I think this is overkill given how simple the change is.
Yes but I don't know whether the untested devices this patch touches are intended to be non hotpluggable. I guess, I'll just ack the
pci.cpart and let Anthony deal with this.
Michael,
PCI hotplug is only supported on x86 via ACPI, and there the piix devices are not hotpluggable.
Re: [Qemu-devel] Re: [PATCH 2/3] piix: tag as not hotpluggable.
Quoted 14 lines · Marcelo Tosatti
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Gerd Hoffmann
Hi,
Quoted 2 lines
Could you split the tested and untested parts to separate patches, noting the status in the commit message?
Quoted 6 lines
Quoted 1 line
I think this is overkill given how simple the change is.
Yes but I don't know whether the untested devices this patch touches are intended to be non hotpluggable. I guess, I'll just ack the
pci.cpart and let Anthony deal with this.
Quoted 4 lines
Michael,
PCI hotplug is only supported on x86 via ACPI, and there the piix devices are not hotpluggable.
Aurelien, could you ack the piix4 bit please?
Signature · 1 line
MST
PATCH 3/3 vga: tag as not hotplugable.
In reply to Gerd HoffmannThis patch tags all vga cards as not hotpluggable. The qemu standard vga will never ever be hotpluggable. For cirrus + vmware it might be possible to get that work some day. Todays we can't handle that for a number of reasons though.
--- hw/cirrus_vga.c | 1 + hw/vga-pci.c | 1 + hw/vmware_vga.c | 1 + 3 files changed, 3 insertions(+), 0 deletions(-)
hw/cirrus_vga.c +1 -0
@@ -3223,6 +3223,7 @@ static PCIDeviceInfo cirrus_vga_info = { .qdev.desc = "Cirrus CLGD 54xx VGA", .qdev.size = sizeof(PCICirrusVGAState), .qdev.vmsd = &vmstate_pci_cirrus_vga, + .no_hotplug = 1, .init = pci_cirrus_vga_initfn, .romfile = VGABIOS_CIRRUS_FILENAME, .config_write = pci_cirrus_write_config,
hw/vga-pci.c +1 -0
@@ -110,6 +110,7 @@ static PCIDeviceInfo vga_info = { .qdev.name = "VGA", .qdev.size = sizeof(PCIVGAState), .qdev.vmsd = &vmstate_vga_pci, + .no_hotplug = 1, .init = pci_vga_initfn, .config_write = pci_vga_write_config, .romfile = "vgabios-stdvga.bin",
hw/vmware_vga.c +1 -0
@@ -1318,6 +1318,7 @@ static PCIDeviceInfo vmsvga_info = { .qdev.name = "vmware-svga", .qdev.size = sizeof(struct pci_vmsvga_state_s), .qdev.vmsd = &vmstate_vmware_vga, + .no_hotplug = 1, .init = pci_vmsvga_initfn, .romfile = "vgabios-vmware.bin", };
Signature · 1 line
1.7.1
Michael S. Tsirkin
AppliedQuoted 5 lines · Gerd Hoffmann
Hi,
This patch series adds a flag which allows pci devices being tagged as not hotpluggable. It also sets this flag for a number of devices.
Quoted 7 lines
cheers,
GerdGerd Hoffmann (3):
pci: allow devices being tagged as not hotpluggable.
piix: tag as not hotpluggable.
vga: tag as not hotplugable.
Applied, thanks.
Quoted 13 lines
hw/acpi_piix4.c | 2 ++ hw/cirrus_vga.c | 1 + hw/ide/piix.c | 2 ++ hw/pci.c | 10 ++++++++++ hw/pci.h | 3 +++ hw/piix4.c | 1 + hw/piix_pci.c | 2 ++ hw/vga-pci.c | 1 + hw/vmware_vga.c | 1 + qerror.c | 4 ++++ qerror.h | 3 +++ 11 files changed, 30 insertions(+), 0 deletions(-)
Quoted 9 lines · Michael S. Tsirkin
Quoted 8 lines · Gerd Hoffmann
Hi,
This patch series adds a flag which allows pci devices being tagged as not hotpluggable. It also sets this flag for a number of devices.
cheers,
Gerd
Quoted 6 lines
Quoted 4 lines
Gerd Hoffmann (3):
pci: allow devices being tagged as not hotpluggable.
piix: tag as not hotpluggable.
vga: tag as not hotplugable.Applied, thanks.
Dropped this from my tree for now, whoever applies the rest of the patches can put in the first one with my ack.
Quoted 13 lines
Quoted 13 lines
hw/acpi_piix4.c | 2 ++ hw/cirrus_vga.c | 1 + hw/ide/piix.c | 2 ++ hw/pci.c | 10 ++++++++++ hw/pci.h | 3 +++ hw/piix4.c | 1 + hw/piix_pci.c | 2 ++ hw/vga-pci.c | 1 + hw/vmware_vga.c | 1 + qerror.c | 4 ++++ qerror.h | 3 +++ 11 files changed, 30 insertions(+), 0 deletions(-)