From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=37274 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnfOd-0001wM-76 for qemu-devel@nongnu.org; Mon, 23 Aug 2010 18:21:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OnfOb-0002eS-SK for qemu-devel@nongnu.org; Mon, 23 Aug 2010 18:21:39 -0400 Received: from mail-iw0-f173.google.com ([209.85.214.173]:39995) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnfOb-0002eF-PS for qemu-devel@nongnu.org; Mon, 23 Aug 2010 18:21:37 -0400 Received: by iwn38 with SMTP id 38so2234289iwn.4 for ; Mon, 23 Aug 2010 15:21:36 -0700 (PDT) Message-ID: <4C72F46D.5040606@codemonkey.ws> Date: Mon, 23 Aug 2010 17:21:33 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 4/5] Add generic drive hotplugging References: <1282600951-30803-1-git-send-email-agraf@suse.de> <1282600951-30803-5-git-send-email-agraf@suse.de> In-Reply-To: <1282600951-30803-5-git-send-email-agraf@suse.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: Markus Armbruster , Luiz Capitulino , qemu-devel List , Aurelien Jarno , Gerd Hoffmann On 08/23/2010 05:02 PM, Alexander Graf wrote: > The monitor command for hotplugging is in i386 specific code. This is just > plain wrong, as S390 just learned how to do hotplugging too and needs to > get drives for that. > > So let's add a generic copy to generic code that handles drive_add in a > way that doesn't have pci dependencies. > > I'm not fully happy with the patch as is. IMHO there should only be a > single target agnostic drive_hot_add function available. How we could > potentially fit IF_SCSI in there I don't know though. > > Signed-off-by: Alexander Graf > I think you really want device_add plus a blockdev_add. Regards, Anthony Liguori > --- > hw/device-hotplug.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 43 insertions(+), 0 deletions(-) > > diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c > index c1a9a56..f311c7f 100644 > --- a/hw/device-hotplug.c > +++ b/hw/device-hotplug.c > @@ -25,6 +25,9 @@ > #include "hw.h" > #include "boards.h" > #include "net.h" > +#include "qemu-config.h" > +#include "sysemu.h" > +#include "monitor.h" > > DriveInfo *add_init_drive(const char *optstr) > { > @@ -44,3 +47,43 @@ DriveInfo *add_init_drive(const char *optstr) > > return dinfo; > } > + > +#if !defined(TARGET_I386) > + > +/* > + * This version of drive_hot_add does not know anything about PCI specifics. > + * It is used as fallback on architectures that don't implement pci-hotplug. > + */ > +void drive_hot_add(Monitor *mon, const QDict *qdict) > +{ > + int type; > + DriveInfo *dinfo = NULL; > + const char *opts = qdict_get_str(qdict, "opts"); > + > + dinfo = add_init_drive(opts); > + if (!dinfo) > + goto err; > + if (dinfo->devaddr) { > + monitor_printf(mon, "Parameter addr not supported\n"); > + goto err; > + } > + type = dinfo->type; > + > + switch (type) { > + case IF_NONE: > + monitor_printf(mon, "OK\n"); > + break; > + default: > + monitor_printf(mon, "Can't hot-add drive to type %d\n", type); > + goto err; > + } > + return; > + > +err: > + if (dinfo) > + drive_uninit(dinfo); > + return; > +} > + > +#endif /* !defined(TARGET_I386) */ > + >