add hotplug opt-out option for pci devices.
v2 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.
[ v2: fix mips build failure ]
[ v2: add patch for qxl ]
Gerd Hoffmann (4):
pci: allow devices being tagged as not hotpluggable.
piix: tag as not hotpluggable.
vga: tag as not hotplugable.
qxl: tag as not hotpluggable
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/qxl.c | 1 + hw/vga-pci.c | 1 + hw/vmware_vga.c | 1 + qerror.c | 4 ++++ qerror.h | 3 +++ 12 files changed, 31 insertions(+), 0 deletions(-)
PATCH v2 1/4 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
@@ -1620,6 +1620,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);
@@ -1652,7 +1657,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
@@ -434,6 +434,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 v2 1/4] 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@@ -1620,6 +1620,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);@@ -1652,7 +1657,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@@ -434,6 +434,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
Re: [Qemu-devel] [PATCH v2 1/4] pci: allow devices being tagged as not hotpluggable.
In reply to Gerd HoffmannQuoted 17 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]>--- hw/pci.c | 10 ++++++++++ hw/pci.h | 3 +++ qerror.c | 4 ++++ qerror.h | 3 +++ 4 files changed, 20 insertions(+), 0 deletions(-)hw/pci.c +0
-0
hw/pci.c static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) · line 1627
Quoted 8 lines
hw/pci.c +5
-0@@ -1620,6 +1620,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 ; + }
Any particular reason for not check this beforedo_pci_register_device()?
Quoted 3 lines
hw/pci.c +0
-0rc = info->init (pci_dev);if (rc !=0 ) {do_pci_unregister_device (pci_dev);
[...]
Quoted 32 lines
hw/pci.c +5
-0@@ -1652,7 +1657,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@@ -434,6 +434,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 +0
-0
qerror.c static const QErrorStringTable qerror_table[] = { · line 107
Quoted 7 lines
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", + }, + {
I'd prefer "can't be hot-plugged", but I doubt it's worth a respin.
Quoted 16 lines
qerror.c +0
-0.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 } }"
Re: [Qemu-devel] [PATCH v2 1/4] pci: allow devices being tagged as not hotpluggable.
Quoted 4 lines
Quoted 4 lines
hw/pci.c +0
-0@@ -1620,6 +1620,11 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) info->is_bridge);if (pci_dev ==NULL )return -1 ;
Quoted 8 lines
hw/pci.c static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) · line 1627
Quoted 5 lines
hw/pci.c +5
-0+if (qdev->hotplugged&& info->no_hotplug) { +qerror_report (QERR_DEVICE_NO_HOTPLUG , info->qdev.name); +do_pci_unregister_device (pci_dev); +return -1 ; + }Any particular reason for not check this before
do_pci_register_device()?
Don't remember, probably not. I think can could be moved up (and loose the unregister call) and behavior will not change.
cheers,
Gerd
PATCH v2 2/4 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
@@ -194,11 +194,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, + .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
Re: [Qemu-devel] [PATCH v2 2/4] piix: tag as not hotpluggable.
Quoted 10 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(-)
I don't know a lot about piix4, but the change looks sane. I have verified it doesn't break the MIPS malta target.
Quoted 68 lines
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@@ -194,11 +194,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, + .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
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH v2 2/4] piix: tag as not hotpluggable.
In reply to Gerd HoffmannQuoted 16 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 +0
-0
hw/acpi_piix4.c static PCIDeviceInfo piix4_pm_info = { · line 431
Quoted 4 lines
hw/acpi_piix4.c +1
-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,
Makes sense, but the commit message doesn't mention it.
Quoted 47 lines
hw/acpi_piix4.c +1
-0+ .no_hotplug = 1, .init = piix4_pm_initfn, .config_write = pm_write_config, .qdev.props = (Property []) {hw/ide/piix.c +2
-0@@ -194,11 +194,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, + .no_hotplug = 1, .init = piix4_initfn, },{/* end of list */ hw/piix_pci.c +1
-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, },{
hw/piix_pci.c static PCIDeviceInfo i440fx_info[] = { · line 363
Quoted 7 lines
hw/piix_pci.c +1
-0@@ -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 */
What about "piix3-usb-uhci" & friends?
Re: [Qemu-devel] [PATCH v2 2/4] piix: tag as not hotpluggable.
Hi,
Quoted 3 lines
Quoted 1 line
+ .no_hotplug = 1,
What about "piix3-usb-uhci"& friends?
Hmm. Good question. UHCI controllers are hotpluggable. But of course it isn't when it is a function of the chipset because pci can hotplug slots only.
Guess the best way to handle this for now is to just disable hotplugging for multifunction slots+devices as qemu currently lacks the infrastructure to handle this correctly.
cheers,
Gerd
PATCH v2 3/4 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
@@ -3227,6 +3227,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
PATCH v2 4/4 qxl: tag as not hotpluggable
In reply to Gerd Hoffmann--- hw/qxl.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
hw/qxl.c +1 -0
@@ -1546,6 +1546,7 @@ static PCIDeviceInfo qxl_info_primary = { .qdev.size = sizeof(PCIQXLDevice), .qdev.reset = qxl_reset_handler, .qdev.vmsd = &qxl_vmstate, + .no_hotplug = 1, .init = qxl_init_primary, .config_write = qxl_write_config, .romfile = "vgabios-qxl.bin",
Signature · 1 line
1.7.1