[libvirt] [PATCH v2 03/10] qemu: Introduce qemuGetHostdevPath
Peter Krempa
pkrempa at redhat.com
Wed Jul 8 13:00:27 UTC 2015
On Mon, Jul 06, 2015 at 13:08:31 -0400, John Ferlan wrote:
> Introduce a convenience function to handle formulating the hostdev path
>
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
> src/qemu/qemu_conf.c | 21 ++++++++++++++++-----
> 1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> index 48fb74a..f82244f 100644
> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -1213,15 +1213,13 @@ qemuIsSharedHostdev(virDomainHostdevDefPtr hostdev)
> return false;
> }
>
> -
Here you end up with one line between functions ...
> static char *
> -qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev)
> +qemuGetHostdevPath(virDomainHostdevDefPtr hostdev)
> {
> virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
> virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
> char *dev_name = NULL;
> char *dev_path = NULL;
> - char *key = NULL;
>
> if (!(dev_name = virSCSIDeviceGetDevName(NULL,
> scsihostsrc->adapter,
> @@ -1230,14 +1228,27 @@ qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev)
> scsihostsrc->unit)))
> goto cleanup;
>
> - if (virAsprintf(&dev_path, "/dev/%s", dev_name) < 0)
> + ignore_value(virAsprintf(&dev_path, "/dev/%s", dev_name));
> +
> + cleanup:
> + VIR_FREE(dev_name);
> + return dev_path;
> +}
> +
> +
... and here you add two.
> +static char *
> +qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev)
> +{
> + char *key = NULL;
> + char *dev_path = NULL;
> +
> + if (!(dev_path = qemuGetHostdevPath(hostdev)))
> goto cleanup;
>
> if (!(key = qemuGetSharedDeviceKey(dev_path)))
> goto cleanup;
>
> cleanup:
> - VIR_FREE(dev_name);
> VIR_FREE(dev_path);
>
> return key;
ACK with whitespace consolidated.
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150708/edd427e7/attachment-0001.sig>
More information about the libvir-list
mailing list