qemu: pass virConnectPtr into Domain{Attach,Detach}*

The qemu RBD driver needs access to the conn in order to get the secret
needed for connecting to the ceph cluster.

Signed-off-by: Sage Weil <sage@newdream.net>
This commit is contained in:
Sage Weil 2011-10-31 13:06:23 -06:00 committed by Eric Blake
parent 381de90375
commit 243f185742
5 changed files with 27 additions and 18 deletions

View File

@ -1497,7 +1497,8 @@ qemuSafeSerialParamValue(const char *value)
char * char *
qemuBuildDriveStr(virDomainDiskDefPtr disk, qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainDiskDefPtr disk,
bool bootable, bool bootable,
virBitmapPtr qemuCaps) virBitmapPtr qemuCaps)
{ {
@ -3912,7 +3913,7 @@ qemuBuildCommandLine(virConnectPtr conn,
deviceFlagMasked = true; deviceFlagMasked = true;
} }
} }
optstr = qemuBuildDriveStr(disk, optstr = qemuBuildDriveStr(conn, disk,
emitBootindex ? false : !!bootindex, emitBootindex ? false : !!bootindex,
qemuCaps); qemuCaps);
if (deviceFlagMasked) if (deviceFlagMasked)

View File

@ -75,7 +75,8 @@ char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
virBitmapPtr qemuCaps); virBitmapPtr qemuCaps);
/* Both legacy & current support */ /* Both legacy & current support */
char *qemuBuildDriveStr(virDomainDiskDefPtr disk, char *qemuBuildDriveStr(virConnectPtr conn,
virDomainDiskDefPtr disk,
bool bootable, bool bootable,
virBitmapPtr qemuCaps); virBitmapPtr qemuCaps);
char *qemuBuildFSStr(virDomainFSDefPtr fs, char *qemuBuildFSStr(virDomainFSDefPtr fs,

View File

@ -5046,7 +5046,8 @@ qemudDomainUndefine(virDomainPtr dom)
} }
static int static int
qemuDomainAttachDeviceDiskLive(struct qemud_driver *driver, qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
struct qemud_driver *driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainDeviceDefPtr dev) virDomainDeviceDefPtr dev)
{ {
@ -5078,12 +5079,12 @@ qemuDomainAttachDeviceDiskLive(struct qemud_driver *driver,
break; break;
case VIR_DOMAIN_DISK_DEVICE_DISK: case VIR_DOMAIN_DISK_DEVICE_DISK:
if (disk->bus == VIR_DOMAIN_DISK_BUS_USB) if (disk->bus == VIR_DOMAIN_DISK_BUS_USB)
ret = qemuDomainAttachUsbMassstorageDevice(driver, vm, ret = qemuDomainAttachUsbMassstorageDevice(conn, driver, vm,
disk); disk);
else if (disk->bus == VIR_DOMAIN_DISK_BUS_VIRTIO) else if (disk->bus == VIR_DOMAIN_DISK_BUS_VIRTIO)
ret = qemuDomainAttachPciDiskDevice(driver, vm, disk); ret = qemuDomainAttachPciDiskDevice(conn, driver, vm, disk);
else if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) else if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI)
ret = qemuDomainAttachSCSIDisk(driver, vm, disk); ret = qemuDomainAttachSCSIDisk(conn, driver, vm, disk);
else else
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("disk bus '%s' cannot be hotplugged."), _("disk bus '%s' cannot be hotplugged."),
@ -5139,7 +5140,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
switch (dev->type) { switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_DISK:
qemuDomainObjCheckDiskTaint(driver, vm, dev->data.disk, -1); qemuDomainObjCheckDiskTaint(driver, vm, dev->data.disk, -1);
ret = qemuDomainAttachDeviceDiskLive(driver, vm, dev); ret = qemuDomainAttachDeviceDiskLive(dom->conn, driver, vm, dev);
if (!ret) if (!ret)
dev->data.disk = NULL; dev->data.disk = NULL;
break; break;

View File

@ -185,7 +185,8 @@ cleanup:
} }
int qemuDomainAttachPciDiskDevice(struct qemud_driver *driver, int qemuDomainAttachPciDiskDevice(virConnectPtr conn,
struct qemud_driver *driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainDiskDefPtr disk) virDomainDiskDefPtr disk)
{ {
@ -221,7 +222,7 @@ int qemuDomainAttachPciDiskDevice(struct qemud_driver *driver,
if (qemuAssignDeviceDiskAlias(disk, priv->qemuCaps) < 0) if (qemuAssignDeviceDiskAlias(disk, priv->qemuCaps) < 0)
goto error; goto error;
if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps))) if (!(drivestr = qemuBuildDriveStr(conn, disk, false, priv->qemuCaps)))
goto error; goto error;
if (!(devstr = qemuBuildDriveDevStr(disk, 0, priv->qemuCaps))) if (!(devstr = qemuBuildDriveDevStr(disk, 0, priv->qemuCaps)))
@ -414,7 +415,8 @@ qemuDomainFindOrCreateSCSIDiskController(struct qemud_driver *driver,
} }
int qemuDomainAttachSCSIDisk(struct qemud_driver *driver, int qemuDomainAttachSCSIDisk(virConnectPtr conn,
struct qemud_driver *driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainDiskDefPtr disk) virDomainDiskDefPtr disk)
{ {
@ -458,7 +460,7 @@ int qemuDomainAttachSCSIDisk(struct qemud_driver *driver,
goto error; goto error;
} }
if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps))) if (!(drivestr = qemuBuildDriveStr(conn, disk, false, priv->qemuCaps)))
goto error; goto error;
for (i = 0 ; i <= disk->info.addr.drive.controller ; i++) { for (i = 0 ; i <= disk->info.addr.drive.controller ; i++) {
@ -538,7 +540,8 @@ error:
} }
int qemuDomainAttachUsbMassstorageDevice(struct qemud_driver *driver, int qemuDomainAttachUsbMassstorageDevice(virConnectPtr conn,
struct qemud_driver *driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainDiskDefPtr disk) virDomainDiskDefPtr disk)
{ {
@ -575,7 +578,7 @@ int qemuDomainAttachUsbMassstorageDevice(struct qemud_driver *driver,
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
if (qemuAssignDeviceDiskAlias(disk, priv->qemuCaps) < 0) if (qemuAssignDeviceDiskAlias(disk, priv->qemuCaps) < 0)
goto error; goto error;
if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps))) if (!(drivestr = qemuBuildDriveStr(conn, disk, false, priv->qemuCaps)))
goto error; goto error;
if (!(devstr = qemuBuildDriveDevStr(disk, 0, priv->qemuCaps))) if (!(devstr = qemuBuildDriveDevStr(disk, 0, priv->qemuCaps)))
goto error; goto error;

View File

@ -1,7 +1,7 @@
/* /*
* qemu_hotplug.h: QEMU device hotplug management * qemu_hotplug.h: QEMU device hotplug management
* *
* Copyright (C) 2006-2007, 2009-2010 Red Hat, Inc. * Copyright (C) 2006-2007, 2009-2011 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange * Copyright (C) 2006 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -33,16 +33,19 @@ int qemuDomainChangeEjectableMedia(struct qemud_driver *driver,
bool force); bool force);
int qemuDomainCheckEjectableMedia(struct qemud_driver *driver, int qemuDomainCheckEjectableMedia(struct qemud_driver *driver,
virDomainObjPtr vm); virDomainObjPtr vm);
int qemuDomainAttachPciDiskDevice(struct qemud_driver *driver, int qemuDomainAttachPciDiskDevice(virConnectPtr conn,
struct qemud_driver *driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainDiskDefPtr disk); virDomainDiskDefPtr disk);
int qemuDomainAttachPciControllerDevice(struct qemud_driver *driver, int qemuDomainAttachPciControllerDevice(struct qemud_driver *driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainControllerDefPtr controller); virDomainControllerDefPtr controller);
int qemuDomainAttachSCSIDisk(struct qemud_driver *driver, int qemuDomainAttachSCSIDisk(virConnectPtr conn,
struct qemud_driver *driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainDiskDefPtr disk); virDomainDiskDefPtr disk);
int qemuDomainAttachUsbMassstorageDevice(struct qemud_driver *driver, int qemuDomainAttachUsbMassstorageDevice(virConnectPtr conn,
struct qemud_driver *driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainDiskDefPtr disk); virDomainDiskDefPtr disk);
int qemuDomainAttachNetDevice(virConnectPtr conn, int qemuDomainAttachNetDevice(virConnectPtr conn,