[libvirt] Re: [PATCH/RFC]: file backed usb massstorage #2

Daniel P. Berrange berrange at redhat.com
Mon Aug 4 09:42:40 UTC 2008


On Sun, Aug 03, 2008 at 01:50:44AM +0200, Guido G?nther wrote:
> diff --git a/src/qemu_conf.c b/src/qemu_conf.c
> index 73039c5..331ff9d 100644
> --- a/src/qemu_conf.c
> +++ b/src/qemu_conf.c
> @@ -883,6 +891,13 @@ int qemudBuildCommandLine(virConnectPtr conn,
>              int idx = virDiskNameToIndex(disk->dst);
>              const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
>  
> +            if (disk->bus == VIR_DOMAIN_DISK_BUS_USB &&
> +                disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
> +                ADD_USBDISK(disk->src);
> +                disk = disk->next;
> +                continue;
> +            }

Should do a 'qemudReportError' if the device type != DISK, so if someone
mistakenly adds a floppy/cdrom it isn't silently ignored.

>              if (idx < 0) {
>                  qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
>                                   _("unsupported disk type '%s'"), disk->dst);
> @@ -922,6 +937,13 @@ int qemudBuildCommandLine(virConnectPtr conn,
>              char dev[NAME_MAX];
>              char file[PATH_MAX];
>  
> +            if (disk->bus == VIR_DOMAIN_DISK_BUS_USB &&
> +                disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
> +                ADD_USBDISK(disk->src);
> +                disk = disk->next;
> +                continue;
> +            }

Same here.

> +
>              if (STREQ(disk->dst, "hdc") &&
>                  disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
>                  if (disk->src) {
> diff --git a/src/qemu_driver.c b/src/qemu_driver.c
> index 1aff53e..018046e 100644
> --- a/src/qemu_driver.c
> +++ b/src/qemu_driver.c
> @@ -2978,6 +2978,44 @@ static int qemudDomainAttachCdromDevice(virDomainPtr dom,
>      return 0;
>  }
>  
> +static int qemudDomainAttachUsbMassstorageDevice(virDomainPtr dom, virDomainDeviceDefPtr dev)
> +{
> +    struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
> +    virDomainObjPtr vm = virDomainFindByUUID(driver->domains, dom->uuid);
> +    int ret;
> +    char *cmd, *reply;
> +
> +    ret = asprintf(&cmd, "usb_add disk:%s", dev->data.disk->src);
> +
> +    if (ret == -1) {
> +        qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
> +                         "%s", _("out of memory"));

Should just be

     qemudReportError(dom->conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);


As with the other patch we need to have an update to the RNG schema
and at least one example test data file in tests/qemuxml2argvdata/
with XML and corresponding ARGV, plumbed into qemuxml2xmltest.c and
qemuxml2argvtest.c

With those changes I'd be happy to see this committed.

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list