misc bugfixes
cover misc bugfixes
Hi,
A bunch of fixes for various bugs, mostly hotplug stuff found by Daniel.
please apply,
Gerd
PATCH 1/4 pci: don't abort() when trying to hotplug with acpi off.
The PCI bus on x86 requires ACPI for hotplug support, thus disbling ACPI also disables hotplug for the PCI bus. This patch makes qemu check whenever the PCI bus in question can handle hotplug before trying to add devices. This is needed because qdev will abort() on any attempt to hotplug devices into a non-hotpluggable bus.
--- hw/pci-hotplug.c | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-)
hw/pci-hotplug.c +16 -1
@@ -40,7 +40,18 @@ static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon, const char *opts_str) {QemuOpts *opts; -int ret; +PCIBus *bus; +int ret, devfn; + + bus =pci_get_bus_devfn (&devfn, devaddr); +if (!bus) { +monitor_printf (mon,"Invalid PCI device address %s\n" , devaddr); +return NULL ; + } +if (!((BusState *)bus)->allow_hotplug) { +monitor_printf (mon,"PCI bus doesn't support hotplug\n" ); +return NULL ; + } opts =qemu_opts_parse (&qemu_net_opts, opts_str ? opts_str :"" ,NULL );if (!opts) {
@@ -179,6 +190,10 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,monitor_printf (mon,"Invalid PCI device address %s\n" , devaddr);return NULL ; } +if (!((BusState *)bus)->allow_hotplug) { +monitor_printf (mon,"PCI bus doesn't support hotplug\n" ); +return NULL ; + }switch (type) {case IF_SCSI :
Signature · 1 line
1.6.5.2
PATCH 2/4 pci: don't hw_error() when no slot is available.
In reply to Gerd HoffmannCurrent PCI code will simply hw_error() and thus abort in case no free PCI slot is available or the requested PCI slot is already in use by another device. For the hotplug case this behavior is not acceptable. This patch makes qemu pass up the error properly, so the calling code can decide whenever it wants to exit with an error (on startup) or whenever it wants to continue (hotplug).
--- hw/pci.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
hw/pci.c +9 -2
@@ -580,11 +580,13 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,if (!bus->devices[devfn]) goto found; } -hw_error ("PCI: no devfn available for %s, all in use\n" , name); +qemu_error ("PCI: no devfn available for %s, all in use\n" , name); +return NULL ; found: ; }else if (bus->devices[devfn]) { -hw_error ("PCI: devfn %d not available for %s, in use by %s\n" , devfn, +qemu_error ("PCI: devfn %d not available for %s, in use by %s\n" , devfn, name, bus->devices[devfn]->name); +return NULL ; } pci_dev->bus = bus; pci_dev->devfn = devfn;
@@ -625,6 +627,9 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name, pci_dev =do_pci_register_device (pci_dev, bus, name, devfn, config_read, config_write,PCI_HEADER_TYPE_NORMAL ); +if (pci_dev ==NULL ) { +hw_error ("PCI: can't register device\n" ); + }return pci_dev; }static target_phys_addr_t pci_to_cpu_addr (target_phys_addr_t addr)
@@ -1376,6 +1381,8 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) pci_dev =do_pci_register_device (pci_dev, bus, base->name, devfn, info->config_read, info->config_write, info->header_type); +if (pci_dev ==NULL ) +return -1 ; rc = info->init (pci_dev);if (rc !=0 )return rc;
Signature · 1 line
1.6.5.2
[Qemu-devel] Re: [FOR 0.12 PATCH 2/4] pci: don't hw_error() when no slot is available.
Quoted 8 lines · Gerd Hoffmann
Current PCI code will simply
hw_error()and thus abort in case no free PCI slot is available or the requested PCI slot is already in use by another device. For the hotplug case this behavior is not acceptable. This patch makes qemu pass up the error properly, so the calling code can decide whenever it wants to exit with an error (on startup) or whenever it wants to continue (hotplug).Signed-off-by Gerd Hoffmann <[email protected]>
Good stuff. However
Quoted 25 lines
--- hw/pci.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)hw/pci.c +4
-2@@ -580,11 +580,13 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,if (!bus->devices[devfn]) goto found; } -hw_error ("PCI: no devfn available for %s, all in use\n" , name); +qemu_error ("PCI: no devfn available for %s, all in use\n" , name); +return NULL ; found: ; }else if (bus->devices[devfn]) { -hw_error ("PCI: devfn %d not available for %s, in use by %s\n" , devfn, +qemu_error ("PCI: devfn %d not available for %s, in use by %s\n" , devfn, name, bus->devices[devfn]->name); +return NULL ; } pci_dev->bus = bus; pci_dev->devfn = devfn;
hw/pci.c PCIDevice *pci_register_device(PCIBus *bus, const char *name, · line 632
Quoted 6 lines
hw/pci.c +3
-0@@ -625,6 +627,9 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name, pci_dev =do_pci_register_device (pci_dev, bus, name, devfn, config_read, config_write,PCI_HEADER_TYPE_NORMAL ); +if (pci_dev ==NULL ) { +hw_error ("PCI: can't register device\n" ); + }
Can you please use !pci_dev for these checks?
hw/pci.c static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) · line 1385
Quoted 9 lines
hw/pci.c +2
-0return pci_dev; }static target_phys_addr_t pci_to_cpu_addr (target_phys_addr_t addr)@@ -1376,6 +1381,8 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) pci_dev =do_pci_register_device (pci_dev, bus, base->name, devfn, info->config_read, info->config_write, info->header_type); +if (pci_dev ==NULL ) +return -1 ;
And here too.
Quoted 7 lines
hw/pci.c +0
-0rc = info->init (pci_dev);if (rc !=0 )return rc;Signature · 1 line
1.6.5.2
[Qemu-devel] Re: [FOR 0.12 PATCH 2/4] pci: don't hw_error() when no slot is available.
Hi,
Quoted 5 lines
hw/pci.c PCIDevice *pci_register_device(PCIBus *bus, const char *name, · line 632
Quoted 3 lines
hw/pci.c +3
-0+if (pci_dev ==NULL ) { +hw_error ("PCI: can't register device\n" ); + }Can you please use !pci_dev for these checks?
Why? IMHO the code is more readable that way. It is easy to miss a single '!' character when reading the code, so I tend to write such tests in a more verbose fashion.
cheers,
Gerd
[Qemu-devel] Re: [FOR 0.12 PATCH 2/4] pci: don't hw_error() when no slot is available.
Quoted 6 lines · Gerd Hoffmann
Hi,
Quoted 4 lines
Quoted 3 lines
hw/pci.c +3
-0+if (pci_dev ==NULL ) { +hw_error ("PCI: can't register device\n" ); + }
Quoted 8 lines
Quoted 1 line
Can you please use !pci_dev for these checks?
Why? IMHO the code is more readable that way. It is easy to miss a single '!' character when reading the code, so I tend to write such tests in a more verbose fashion.
cheers,
Gerd
Reader has limited short term memory. Don't fill it up with irrelevant detail. In places where it might be confusing, a comment might be appropriate, this is not one of them.
C is a terse language. !x is a standard idiom. Let's use it.
Signature · 1 line
MST
Re: [Qemu-devel] Re: [FOR 0.12 PATCH 2/4] pci: don't hw_error() when no slot is available.
Quoted 13 lines · Michael S. Tsirkin
Quoted 12 lines · Gerd Hoffmann
Hi,
Quoted 5 lines
hw/pci.c PCIDevice *pci_register_device(PCIBus *bus, const char *name, · line 632
Quoted 3 lines
hw/pci.c +3
-0+if (pci_dev ==NULL ) { +hw_error ("PCI: can't register device\n" ); + }Can you please use !pci_dev for these checks?
Why? IMHO the code is more readable that way. It is easy to miss a single '!' character when reading the code, so I tend to write such tests in a more verbose fashion.
Quoted 9 lines
Quoted 2 lines
cheers,
GerdReader has limited short term memory. Don't fill it up with irrelevant detail. In places where it might be confusing, a comment might be appropriate, this is not one of them.
C is a terse language. !x is a standard idiom. Let's use it.
! is for boolean. pci_dev is not boolean.
--
Gleb.
Re: [Qemu-devel] Re: [FOR 0.12 PATCH 2/4] pci: don't hw_error() when no slot is available.
Quoted 17 lines · Gleb Natapov
Quoted 16 lines · Michael S. Tsirkin
Quoted 14 lines · Gerd Hoffmann
Hi,
Quoted 5 lines
hw/pci.c PCIDevice *pci_register_device(PCIBus *bus, const char *name, · line 632
Quoted 3 lines
hw/pci.c +3
-0+if (pci_dev ==NULL ) { +hw_error ("PCI: can't register device\n" ); + }Can you please use !pci_dev for these checks?
Why? IMHO the code is more readable that way. It is easy to miss a single '!' character when reading the code, so I tend to write such tests in a more verbose fashion.
cheers,
Gerd
Quoted 7 lines
Quoted 6 lines
Reader has limited short term memory. Don't fill it up with irrelevant detail. In places where it might be confusing, a comment might be appropriate, this is not one of them.
C is a terse language. !x is a standard idiom. Let's use it.
! is for boolean.
In which language? Not in C.
Quoted 3 lines
pci_devis not boolean.
--
Gleb.
Re: [Qemu-devel] Re: [FOR 0.12 PATCH 2/4] pci: don't hw_error() when no slot is available.
Quoted 22 lines · Michael S. Tsirkin
Quoted 21 lines · Gleb Natapov
Quoted 20 lines · Michael S. Tsirkin
Quoted 6 lines · Gerd Hoffmann
Hi,
Quoted 4 lines
Quoted 3 lines
hw/pci.c +3
-0+if (pci_dev ==NULL ) { +hw_error ("PCI: can't register device\n" ); + }Quoted 8 lines
Quoted 1 line
Can you please use !pci_dev for these checks?
Why? IMHO the code is more readable that way. It is easy to miss a single '!' character when reading the code, so I tend to write such tests in a more verbose fashion.
cheers,
GerdReader has limited short term memory. Don't fill it up with irrelevant detail. In places where it might be confusing, a comment might be appropriate, this is not one of them.
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
C is a terse language. !x is a standard idiom. Let's use it.
! is for boolean.
In which language? Not in C.
In boolean. My point is no need to force your style on everyone if it is not in coding style document. == often much more readable then !.
Quoted 3 lines
Quoted 3 lines
pci_devis not boolean.
--
Gleb.
--
Gleb.
Re: [Qemu-devel] Re: [FOR 0.12 PATCH 2/4] pci: don't hw_error() when no slot is available.
Quoted 23 lines · Gleb Natapov
Quoted 22 lines · Michael S. Tsirkin
Quoted 21 lines · Gleb Natapov
Quoted 20 lines · Michael S. Tsirkin
Quoted 6 lines · Gerd Hoffmann
Hi,
Quoted 4 lines
Quoted 3 lines
(quoted diff) +3
-0+ if (pci_dev == NULL) { + hw_error("PCI: can't register device\n"); + }Quoted 8 lines
Quoted 1 line
Can you please use !pci_dev for these checks?
Why? IMHO the code is more readable that way. It is easy to miss a single '!' character when reading the code, so I tend to write such tests in a more verbose fashion.
cheers,
GerdReader has limited short term memory. Don't fill it up with irrelevant detail. In places where it might be confusing, a comment might be appropriate, this is not one of them.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
C is a terse language. !x is a standard idiom. Let's use it.
! is for boolean.
In which language? Not in C.
In boolean. My point is no need to force your style on everyone
I am not forcing style on anyone - how can I do this? I hacked on pci and by now there's no == NULL in pci.c anywhere ;). I will be happier if none is added now.
Quoted 1 line
if it is not in coding style document.
Heh, we don't need to document everything.
Quoted 1 line
== often much more readable then !.
Matter of taste probably.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
pci_devis not boolean.
--
Gleb.--
Gleb.
Re: [Qemu-devel] Re: [FOR 0.12 PATCH 2/4] pci: don't hw_error() when no slot is available.
Quoted 36 lines · Michael S. Tsirkin
Quoted 23 lines · Gleb Natapov
Quoted 22 lines · Michael S. Tsirkin
Quoted 21 lines · Gleb Natapov
Quoted 20 lines · Michael S. Tsirkin
Quoted 6 lines · Gerd Hoffmann
Hi,
Quoted 4 lines
Quoted 3 lines
(quoted diff) +3
-0+ if (pci_dev == NULL) { + hw_error("PCI: can't register device\n"); + }Quoted 8 lines
Quoted 1 line
Can you please use !pci_dev for these checks?
Why? IMHO the code is more readable that way. It is easy to miss a single '!' character when reading the code, so I tend to write such tests in a more verbose fashion.
cheers,
GerdReader has limited short term memory. Don't fill it up with irrelevant detail. In places where it might be confusing, a comment might be appropriate, this is not one of them.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
C is a terse language. !x is a standard idiom. Let's use it.
! is for boolean.
In which language? Not in C.
In boolean. My point is no need to force your style on everyone
I am not forcing style on anyone - how can I do this? I hacked on pci and by now there's no == NULL in
pci.canywhere ;). I will be happier if none is added now.
Quoted 8 lines
Quoted 1 line
if it is not in coding style document.
Heh, we don't need to document everything.
Quoted 1 line
== often much more readable then !.
Matter of taste probably.
Exactly! (Or should I say "Exactly=="?)
--
Gleb.
Re: [Qemu-devel] Re: [FOR 0.12 PATCH 2/4] pci: don't hw_error() when no slot is available.
In reply to Michael S. TsirkinQuoted 47 lines · Michael S. Tsirkin
Quoted 8 lines · Gerd Hoffmann
Current PCI code will simply
hw_error()and thus abort in case no free PCI slot is available or the requested PCI slot is already in use by another device. For the hotplug case this behavior is not acceptable. This patch makes qemu pass up the error properly, so the calling code can decide whenever it wants to exit with an error (on startup) or whenever it wants to continue (hotplug).Signed-off-by Gerd Hoffmann <[email protected]>Good stuff. However
Quoted 25 lines
---
hw/pci.c| 11 +++++++++--1 files changed, 9 insertions(+), 2 deletions(-)hw/pci.c +4
-2@@ -580,11 +580,13 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,if (!bus->devices[devfn]) goto found; } -hw_error ("PCI: no devfn available for %s, all in use\n" , name); +qemu_error ("PCI: no devfn available for %s, all in use\n" , name); +return NULL ; found: ; }else if (bus->devices[devfn]) { -hw_error ("PCI: devfn %d not available for %s, in use by %s\n" , devfn, +qemu_error ("PCI: devfn %d not available for %s, in use by %s\n" , devfn, name, bus->devices[devfn]->name); +return NULL ; } pci_dev->bus = bus; pci_dev->devfn = devfn;hw/pci.c PCIDevice *pci_register_device(PCIBus *bus, const char *name, · line 632
Quoted 6 lines
hw/pci.c +3
-0@@ -625,6 +627,9 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name, pci_dev =do_pci_register_device (pci_dev, bus, name, devfn, config_read, config_write,PCI_HEADER_TYPE_NORMAL ); +if (pci_dev ==NULL ) { +hw_error ("PCI: can't register device\n" ); + }Can you please use !pci_dev for these checks?
Quoted 11 lines
hw/pci.c static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) · line 1385
Quoted 9 lines
hw/pci.c +2
-0return pci_dev; }static target_phys_addr_t pci_to_cpu_addr (target_phys_addr_t addr)@@ -1376,6 +1381,8 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) pci_dev =do_pci_register_device (pci_dev, bus, base->name, devfn, info->config_read, info->config_write, info->header_type); +if (pci_dev ==NULL ) +return -1 ;And here too.
OMG! Broken coding style!
:)
Alex
PATCH 3/4 scsi: fix drive hotplug.
In reply to Gerd HoffmannThis patch fills the DriveInfo->unit after hotplugging a scsi disk. It makes a difference when auto-assigning a scsi id, where unit was left filled with '-1' instead of the actual scsi id.
With this patch applied the the drive naming logic in drive_init() works as good as it did in previous releases. Which means it works fine with a single scsi bus.
--- hw/pci-hotplug.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
hw/pci-hotplug.c +1 -0
@@ -93,6 +93,7 @@ static int scsi_hot_add(DeviceState *adapter, DriveInfo *dinfo, int printinfo)*/ dinfo->unit =qemu_opt_get_number (dinfo->opts,"unit" ,-1 ); scsidev =scsi_bus_legacy_add_drive (scsibus, dinfo, dinfo->unit); + dinfo->unit = scsidev->id;if (printinfo)qemu_error ("OK bus %d, unit %d\n" , scsibus->busnr, scsidev->id);
Signature · 1 line
1.6.5.2
PATCH 4/4 QemuOpts: allow larger option values.
In reply to Gerd HoffmannUse case: loooooooooooooooooong file names for -drive file=...
--- qemu-option.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
qemu-option.c +2 -2
@@ -705,7 +705,7 @@ int qemu_opts_print(QemuOpts *opts, void *dummy)int qemu_opts_do_parse (QemuOpts *opts,const char *params,const char *firstname) { -char option[128 ], value[128 ]; +char option[128 ], value[1024 ];const char *p,*pe,*pc;for (p = params; *p !='\0' ; p++) {
@@ -751,7 +751,7 @@ int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstnameQemuOpts *qemu_opts_parse (QemuOptsList *list,const char *params,const char *firstname) { -char value[128 ], *id =NULL ; +char value[1024 ], *id =NULL ;const char *p;QemuOpts *opts;
Signature · 1 line
1.6.5.2
Quoted 7 lines · Gerd Hoffmann
Hi,
A bunch of fixes for various bugs, mostly hotplug stuff found by Daniel.
please apply,
Gerd
I am kind of confused by the FOR 0.12 prefix - these patches are not on master yet, are they? Should patches land on master before being backported to 0.12?
Signature · 1 line
MST
Quoted 11 lines · Michael S. Tsirkin
Quoted 7 lines · Gerd Hoffmann
Hi,A bunch of fixes for various bugs, mostly hotplug stuff found by Daniel.
please apply,
GerdI am kind of confused by the FOR 0.12 prefix - these patches are not on master yet, are they?
No.
Quoted 2 lines
Should patches land on master before being backported to 0.12?
Anthony asked to tag patches this way if they should be merged for the 0.12 release. So, after branching, they should go to both master and 0.12 I think. Do we have a 0.12 branch already?
cheers,
Gerd
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Gerd Hoffmann
Hi,
A bunch of fixes for various bugs, mostly hotplug stuff found by Daniel.
please apply,
Gerd
Quoted 5 lines
I am kind of confused by the FOR 0.12 prefix - these patches are not on master yet, are they? Should patches land on master before being backported to 0.12?
Right now, there's almost no difference between master and stable-0.12. I always commit to master first and then cherry pick.
FOR 0.12 helps me know that I need to cherry pick from master into stable-0.12.
Regards,
Anthony Liguori