From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH 7/7] KVM/userspace: Device Assignment: Support for hot plugging PCI devices Date: Tue, 23 Sep 2008 11:32:04 -0500 Message-ID: <48D91A04.3000501@codemonkey.ws> References: <1222181695-23418-1-git-send-email-amit.shah@redhat.com> <1222181695-23418-2-git-send-email-amit.shah@redhat.com> <1222181695-23418-3-git-send-email-amit.shah@redhat.com> <1222181695-23418-4-git-send-email-amit.shah@redhat.com> <1222181695-23418-5-git-send-email-amit.shah@redhat.com> <1222181695-23418-6-git-send-email-amit.shah@redhat.com> <1222181695-23418-7-git-send-email-amit.shah@redhat.com> <1222181695-23418-8-git-send-email-amit.shah@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: avi@redhat.com, kvm@vger.kernel.org, muli@il.ibm.com, benami@il.ibm.com, weidong.han@intel.com, allen.m.kay@intel.com To: Amit Shah Return-path: Received: from nf-out-0910.google.com ([64.233.182.186]:63509 "EHLO nf-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751538AbYIWQdG (ORCPT ); Tue, 23 Sep 2008 12:33:06 -0400 Received: by nf-out-0910.google.com with SMTP id d3so739141nfc.21 for ; Tue, 23 Sep 2008 09:33:04 -0700 (PDT) In-Reply-To: <1222181695-23418-8-git-send-email-amit.shah@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Amit Shah wrote: > This patch adds support for hot-plugging host PCI devices into > guests > Instead of using assigned, it should probably be host. Regards, Anthony Liguori > Signed-off-by: Amit Shah > --- > qemu/hw/device-hotplug.c | 19 +++++++++++++++++++ > qemu/monitor.c | 2 +- > 2 files changed, 20 insertions(+), 1 deletions(-) > > diff --git a/qemu/hw/device-hotplug.c b/qemu/hw/device-hotplug.c > index 8e2bc35..6d2ab8e 100644 > --- a/qemu/hw/device-hotplug.c > +++ b/qemu/hw/device-hotplug.c > @@ -6,6 +6,7 @@ > #include "pc.h" > #include "console.h" > #include "block_int.h" > +#include "device-assignment.h" > > #define PCI_BASE_CLASS_STORAGE 0x01 > #define PCI_BASE_CLASS_NETWORK 0x02 > @@ -27,6 +28,22 @@ static PCIDevice *qemu_system_hot_add_nic(const char *opts, int bus_nr) > return pci_nic_init (pci_bus, &nd_table[ret], -1); > } > > +static PCIDevice *qemu_system_hot_assign_device(const char *opts, int bus_nr) > +{ > + int index; > + PCIBus *pci_bus; > + > + pci_bus = pci_find_bus(bus_nr); > + if (!pci_bus) { > + term_printf ("Can't find pci_bus %d\n", bus_nr); > + return NULL; > + } > + add_assigned_device(opts); > + > + index = -1; > + return init_assigned_device(pci_bus, &index); > +} > + > static int add_init_drive(const char *opts) > { > int drive_opt_idx, drive_idx; > @@ -143,6 +160,8 @@ void device_hot_add(int pcibus, const char *type, const char *opts) > dev = qemu_system_hot_add_nic(opts, pcibus); > else if (strcmp(type, "storage") == 0) > dev = qemu_system_hot_add_storage(opts, pcibus); > + else if (strcmp(type, "assigned") == 0) > + dev = qemu_system_hot_assign_device(opts, pcibus); > else > term_printf("invalid type: %s\n", type); > > diff --git a/qemu/monitor.c b/qemu/monitor.c > index 2619fdd..6cf5e8a 100644 > --- a/qemu/monitor.c > +++ b/qemu/monitor.c > @@ -1516,7 +1516,7 @@ static term_cmd_t term_cmds[] = { > "[,cyls=c,heads=h,secs=s[,trans=t]]\n" > "[snapshot=on|off][,cache=on|off]", > "add drive to PCI storage controller" }, > - { "pci_add", "iss", device_hot_add, "bus nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...", "hot-add PCI device" }, > + { "pci_add", "iss", device_hot_add, "bus nic|storage|assigned [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]... [host=02:00.0[,name=string][,dma=none]" "hot-add PCI device" }, > { "pci_del", "ii", device_hot_remove, "bus slot-number", "hot remove PCI device" }, > #endif > { "balloon", "i", do_balloon, >