mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 15:52:55 +00:00
qemu: Inline qemuGetHostdevPath
Since a future patch will need the device path generated when adding a shared host device, remove the qemuAddSharedHostdev and inline the two calls into qemuAddSharedHostdev and qemuRemoveSharedHostdev Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
f6a5cbbfdc
commit
3830795318
@ -1267,11 +1267,17 @@ qemuGetHostdevPath(virDomainHostdevDefPtr hostdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *
|
static int
|
||||||
qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev)
|
qemuAddSharedHostdev(virQEMUDriverPtr driver,
|
||||||
|
virDomainHostdevDefPtr hostdev,
|
||||||
|
const char *name)
|
||||||
{
|
{
|
||||||
char *key = NULL;
|
|
||||||
char *dev_path = NULL;
|
char *dev_path = NULL;
|
||||||
|
char *key = NULL;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
if (!qemuIsSharedHostdev(hostdev))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (!(dev_path = qemuGetHostdevPath(hostdev)))
|
if (!(dev_path = qemuGetHostdevPath(hostdev)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1279,31 +1285,12 @@ qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev)
|
|||||||
if (!(key = qemuGetSharedDeviceKey(dev_path)))
|
if (!(key = qemuGetSharedDeviceKey(dev_path)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(dev_path);
|
|
||||||
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
qemuAddSharedHostdev(virQEMUDriverPtr driver,
|
|
||||||
virDomainHostdevDefPtr hostdev,
|
|
||||||
const char *name)
|
|
||||||
{
|
|
||||||
char *key = NULL;
|
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!qemuIsSharedHostdev(hostdev))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!(key = qemuGetSharedHostdevKey(hostdev)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
ret = qemuSharedDeviceEntryInsert(driver, key, name);
|
ret = qemuSharedDeviceEntryInsert(driver, key, name);
|
||||||
qemuDriverUnlock(driver);
|
qemuDriverUnlock(driver);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(dev_path);
|
||||||
VIR_FREE(key);
|
VIR_FREE(key);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1392,19 +1379,25 @@ qemuRemoveSharedHostdev(virQEMUDriverPtr driver,
|
|||||||
virDomainHostdevDefPtr hostdev,
|
virDomainHostdevDefPtr hostdev,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
|
char *dev_path = NULL;
|
||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!qemuIsSharedHostdev(hostdev))
|
if (!qemuIsSharedHostdev(hostdev))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(key = qemuGetSharedHostdevKey(hostdev)))
|
if (!(dev_path = qemuGetHostdevPath(hostdev)))
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (!(key = qemuGetSharedDeviceKey(dev_path)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
ret = qemuSharedDeviceEntryRemove(driver, key, name);
|
ret = qemuSharedDeviceEntryRemove(driver, key, name);
|
||||||
qemuDriverUnlock(driver);
|
qemuDriverUnlock(driver);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(dev_path);
|
||||||
VIR_FREE(key);
|
VIR_FREE(key);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user