From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MJx3G-0002My-Kj for qemu-devel@nongnu.org; Thu, 25 Jun 2009 18:04:14 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MJx3C-0002MV-3Q for qemu-devel@nongnu.org; Thu, 25 Jun 2009 18:04:14 -0400 Received: from [199.232.76.173] (port=53008 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MJx3C-0002MS-1V for qemu-devel@nongnu.org; Thu, 25 Jun 2009 18:04:10 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:33784) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MJx3B-0001Og-85 for qemu-devel@nongnu.org; Thu, 25 Jun 2009 18:04:09 -0400 Message-ID: <4A43F450.9060207@web.de> Date: Fri, 26 Jun 2009 00:04:00 +0200 From: Jan Kiszka MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigB296A3B195B2EE55A851861E" Sender: jan.kiszka@web.de Subject: [Qemu-devel] [PATCH 1/2] monitor: Drop pci_addr prefix from hotplug commands List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB296A3B195B2EE55A851861E Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable The "pci_addr=3D" prefix currently required by pci_add/remove and drive_add has no practical use. Drop it, but still silently accept it for backward compatibility. Signed-off-by: Jan Kiszka --- hw/pci-hotplug.c | 22 +++++++++------------- hw/pci.c | 16 ++++++++++------ hw/pci.h | 3 ++- qemu-monitor.hx | 6 +++--- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index 952e27a..f7d38a7 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -56,8 +56,7 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, = const char *opts) int success =3D 0; PCIDevice *dev; =20 - if (pci_read_devaddr(pci_addr, &dom, &pci_bus, &slot)) { - monitor_printf(mon, "Invalid pci address\n"); + if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) { return; } =20 @@ -148,21 +147,19 @@ void pci_device_hot_add(Monitor *mon, const char *p= ci_addr, const char *type, const char *opts) { PCIDevice *dev =3D NULL; - const char *devaddr =3D NULL; - char buf[32]; =20 - if (!get_param_value(buf, sizeof(buf), "pci_addr", pci_addr)) { - monitor_printf(mon, "Invalid pci address\n"); - return; + /* strip legacy tag */ + if (!strncmp(pci_addr, "pci_addr=3D", 9)) { + pci_addr +=3D 9; } =20 - if (strcmp(buf, "auto")) - devaddr =3D buf; + if (!strcmp(pci_addr, "auto")) + pci_addr =3D NULL; =20 if (strcmp(type, "nic") =3D=3D 0) - dev =3D qemu_pci_hot_add_nic(mon, devaddr, opts); + dev =3D qemu_pci_hot_add_nic(mon, pci_addr, opts); else if (strcmp(type, "storage") =3D=3D 0) - dev =3D qemu_pci_hot_add_storage(mon, devaddr, opts); + dev =3D qemu_pci_hot_add_storage(mon, pci_addr, opts); else monitor_printf(mon, "invalid type: %s\n", type); =20 @@ -183,8 +180,7 @@ void pci_device_hot_remove(Monitor *mon, const char *= pci_addr) int dom, bus; unsigned slot; =20 - if (pci_read_devaddr(pci_addr, &dom, &bus, &slot)) { - monitor_printf(mon, "Invalid pci address\n"); + if (pci_read_devaddr(mon, pci_addr, &dom, &bus, &slot)) { return; } =20 diff --git a/hw/pci.c b/hw/pci.c index f2d7daf..57f4060 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -227,14 +227,18 @@ static int pci_parse_devaddr(const char *addr, int = *domp, int *busp, unsigned *s return 0; } =20 -int pci_read_devaddr(const char *addr, int *domp, int *busp, unsigned *s= lotp) +int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *bus= p, + unsigned *slotp) { - char devaddr[32]; - - if (!get_param_value(devaddr, sizeof(devaddr), "pci_addr", addr)) + /* strip legacy tag */ + if (!strncmp(addr, "pci_addr=3D", 9)) { + addr +=3D 9; + } + if (pci_parse_devaddr(addr, domp, busp, slotp)) { + monitor_printf(mon, "Invalid pci address\n"); return -1; - - return pci_parse_devaddr(devaddr, domp, busp, slotp); + } + return 0; } =20 static PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr) diff --git a/hw/pci.h b/hw/pci.h index c8625de..3be660c 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -192,7 +192,8 @@ void pci_for_each_device(int bus_num, void (*fn)(PCID= evice *d)); PCIBus *pci_find_bus(int bus_num); PCIDevice *pci_find_device(int bus_num, int slot, int function); =20 -int pci_read_devaddr(const char *addr, int *domp, int *busp, unsigned *s= lotp); +int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *bus= p, + unsigned *slotp); =20 void pci_info(Monitor *mon); PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid, uint16_t d= id, diff --git a/qemu-monitor.hx b/qemu-monitor.hx index d7c7078..2ea9840 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -493,7 +493,7 @@ Set maximum tolerated downtime (in seconds) for migra= tion. ETEXI =20 #if defined(TARGET_I386) - { "drive_add", "ss", drive_hot_add, "pci_addr=3D[[:]:]<= slot>\n" + { "drive_add", "ss", drive_hot_add, "[[:]:]\n" "[file=3Dfile][,if=3Dtype][,bus= =3Dn]\n" "[,unit=3Dm][,media=3Dd][index=3D= i]\n" "[,cyls=3Dc,heads=3Dh,secs=3Ds[,= trans=3Dt]]\n" @@ -506,7 +506,7 @@ Add drive to PCI storage controller. ETEXI =20 #if defined(TARGET_I386) - { "pci_add", "sss", pci_device_hot_add, "pci_addr=3Dauto|[[:= ]:] nic|storage [[vlan=3Dn][,macaddr=3Daddr][,model=3Dtype]] [= file=3Dfile][,if=3Dtype][,bus=3Dnr]...", "hot-add PCI device" }, + { "pci_add", "sss", pci_device_hot_add, "auto|[[:]:] nic|storage [[vlan=3Dn][,macaddr=3Daddr][,model=3Dtype]] [file=3Dfile= ][,if=3Dtype][,bus=3Dnr]...", "hot-add PCI device" }, #endif STEXI @item pci_add @@ -514,7 +514,7 @@ Hot-add PCI device. ETEXI =20 #if defined(TARGET_I386) - { "pci_del", "s", pci_device_hot_remove, "pci_addr=3D[[:]:]", "hot remove PCI device" }, + { "pci_del", "s", pci_device_hot_remove, "[[:]:]"= , "hot remove PCI device" }, #endif STEXI @item pci_del --------------enigB296A3B195B2EE55A851861E Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkpD9FUACgkQniDOoMHTA+nbcACfVDn6+iQjAfjeJyp6yTDsmi3g Qg4AnRbyI4yA032LqVk6hfmj927AJyhy =Xa4c -----END PGP SIGNATURE----- --------------enigB296A3B195B2EE55A851861E--