mirror of https://gitee.com/openkylin/libvirt.git
virfile: refactor virFileNBDDeviceAssociate
The only reason why virstoragefile.h needs to be included in virfile.h is that virFileNBDDeviceAssociate() takes virStorageFileFormat argument. The function doesn't need the enum value as it converts the value to string and uses only that. Change the argument to string which will allow us to remove that include. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
b2b1702341
commit
e1894cf490
|
@ -509,7 +509,7 @@ static int virLXCControllerSetupNBDDeviceFS(virDomainFSDefPtr fs)
|
|||
}
|
||||
|
||||
if (virFileNBDDeviceAssociate(fs->src->path,
|
||||
fs->format,
|
||||
virStorageFileFormatTypeToString(fs->format),
|
||||
fs->readonly,
|
||||
&dev) < 0)
|
||||
return -1;
|
||||
|
@ -541,7 +541,7 @@ static int virLXCControllerSetupNBDDeviceDisk(virDomainDiskDefPtr disk)
|
|||
}
|
||||
|
||||
if (virFileNBDDeviceAssociate(src,
|
||||
format,
|
||||
virStorageFileFormatTypeToString(format),
|
||||
disk->src->readonly,
|
||||
&dev) < 0)
|
||||
return -1;
|
||||
|
|
|
@ -879,14 +879,13 @@ virFileNBDLoadDriver(void)
|
|||
}
|
||||
|
||||
int virFileNBDDeviceAssociate(const char *file,
|
||||
virStorageFileFormat fmt,
|
||||
const char *fmtstr,
|
||||
bool readonly,
|
||||
char **dev)
|
||||
{
|
||||
g_autofree char *nbddev = NULL;
|
||||
g_autofree char *qemunbd = NULL;
|
||||
g_autoptr(virCommand) cmd = NULL;
|
||||
const char *fmtstr = NULL;
|
||||
|
||||
if (!virFileNBDLoadDriver())
|
||||
return -1;
|
||||
|
@ -900,9 +899,6 @@ int virFileNBDDeviceAssociate(const char *file,
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (fmt > 0)
|
||||
fmtstr = virStorageFileFormatTypeToString(fmt);
|
||||
|
||||
cmd = virCommandNew(qemunbd);
|
||||
|
||||
/* Explicitly not trying to cope with old qemu-nbd which
|
||||
|
@ -945,7 +941,7 @@ int virFileLoopDeviceAssociate(const char *file,
|
|||
}
|
||||
|
||||
int virFileNBDDeviceAssociate(const char *file,
|
||||
virStorageFileFormat fmt G_GNUC_UNUSED,
|
||||
const char *fmtstr G_GNUC_UNUSED,
|
||||
bool readonly G_GNUC_UNUSED,
|
||||
char **dev G_GNUC_UNUSED)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "internal.h"
|
||||
#include "virbitmap.h"
|
||||
#include "virstoragefile.h"
|
||||
#include "virenum.h"
|
||||
|
||||
typedef enum {
|
||||
|
@ -144,7 +143,7 @@ int virFileLoopDeviceAssociate(const char *file,
|
|||
char **dev);
|
||||
|
||||
int virFileNBDDeviceAssociate(const char *file,
|
||||
virStorageFileFormat fmt,
|
||||
const char *fmtstr,
|
||||
bool readonly,
|
||||
char **dev);
|
||||
|
||||
|
|
Loading…
Reference in New Issue