[libvirt] [PATCH 2/2] Support virDomainAttachDevice and virDomainDetachDevice for disks in UML
Matthias Bolte
matthias.bolte at googlemail.com
Tue Aug 24 20:20:04 UTC 2010
2010/8/23 <soren at linux2go.dk>:
> From: Soren Hansen <soren at linux2go.dk>
>
> UML supports hot plugging and unplugging of various devices. This patch
> exposes this functionality for disks.
>
> Signed-off-by: Soren Hansen <soren at linux2go.dk>
> ---
> src/uml/uml_driver.c | 239 +++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 235 insertions(+), 4 deletions(-)
>
> diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
> index 9cad7f1..a5c5d6a 100644
> --- a/src/uml/uml_driver.c
> +++ b/src/uml/uml_driver.c
> @@ -1683,6 +1683,237 @@ cleanup:
> }
>
>
> +static int umlDomainAttachUmlDisk(struct uml_driver *driver,
> + virDomainObjPtr vm,
> + virDomainDiskDefPtr disk)
> +{
> + int i, ret;
> + char *cmd = NULL;
> + char *reply = NULL;
> +
> + for (i = 0 ; i < vm->def->ndisks ; i++) {
> + if (STREQ(vm->def->disks[i]->dst, disk->dst)) {
> + umlReportError(VIR_ERR_OPERATION_FAILED,
> + _("target %s already exists"), disk->dst);
> + return -1;
> + }
> + }
> +
> + if (!disk->src) {
> + umlReportError(VIR_ERR_INTERNAL_ERROR,
> + "%s", _("disk source path is missing"));
> + goto error;
> + }
> +
> + if (virAsprintf(&cmd, "config %s=%s", disk->dst, disk->src) < 0) {
> + virReportOOMError();
> + return -1;
> + }
> +
> + if (umlMonitorCommand(driver, vm, cmd, &reply) < 0)
> + goto error;
> +
> + if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) {
> + virReportOOMError();
> + goto error;
> + }
> +
> + if (ret < 0)
> + goto error;
I was about to push this patch, but compile testing gave this error:
uml/uml_driver.c: In function 'umlDomainAttachUmlDisk':
uml/uml_driver.c:1729: error: 'ret' may be used uninitialized in this
function [-Wuninitialized]
I think "if (ret < 0) goto error;" and "int ret;" can just be removed
completely from this function, but I would like have your ACK on this
before doing so.
Matthias
More information about the libvir-list
mailing list