mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
storage: use enum for default driver type
Express the default disk type as an enum, for easier handling. * src/conf/capabilities.h (_virCaps): Store enum rather than string for disk type. * src/conf/domain_conf.c (virDomainDiskDefParseXML): Adjust clients. * src/qemu/qemu_driver.c (qemuCreateCapabilities): Likewise.
This commit is contained in:
parent
e2c41e4860
commit
09e7fb5e1f
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* capabilities.h: hypervisor capabilities
|
||||
*
|
||||
* Copyright (C) 2006-2008, 2010 Red Hat, Inc.
|
||||
* Copyright (C) 2006-2008, 2010, 2012 Red Hat, Inc.
|
||||
* Copyright (C) 2006-2008 Daniel P. Berrange
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@ -149,7 +149,7 @@ struct _virCaps {
|
||||
unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
|
||||
unsigned int emulatorRequired : 1;
|
||||
const char *defaultDiskDriverName;
|
||||
const char *defaultDiskDriverType;
|
||||
int defaultDiskDriverType; /* enum virStorageFileFormat */
|
||||
int (*defaultConsoleTargetType)(const char *ostype);
|
||||
void *(*privateDataAllocFunc)(void);
|
||||
void (*privateDataFreeFunc)(void *);
|
||||
|
@ -4192,7 +4192,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
|
||||
|
||||
if (!def->driverType &&
|
||||
caps->defaultDiskDriverType &&
|
||||
!(def->driverType = strdup(caps->defaultDiskDriverType)))
|
||||
!(def->driverType = strdup(virStorageFileFormatTypeToString(
|
||||
caps->defaultDiskDriverType))))
|
||||
goto no_memory;
|
||||
|
||||
if (!def->driverName &&
|
||||
@ -4203,7 +4204,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
|
||||
|
||||
if (def->mirror && !def->mirrorFormat &&
|
||||
caps->defaultDiskDriverType &&
|
||||
!(def->mirrorFormat = strdup(caps->defaultDiskDriverType)))
|
||||
!(def->mirrorFormat = strdup(virStorageFileFormatTypeToString(
|
||||
caps->defaultDiskDriverType))))
|
||||
goto no_memory;
|
||||
|
||||
if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE
|
||||
|
@ -394,10 +394,10 @@ qemuCreateCapabilities(struct qemud_driver *driver)
|
||||
|
||||
if (driver->allowDiskFormatProbing) {
|
||||
caps->defaultDiskDriverName = NULL;
|
||||
caps->defaultDiskDriverType = NULL;
|
||||
caps->defaultDiskDriverType = VIR_STORAGE_FILE_AUTO;
|
||||
} else {
|
||||
caps->defaultDiskDriverName = "qemu";
|
||||
caps->defaultDiskDriverType = "raw";
|
||||
caps->defaultDiskDriverType = VIR_STORAGE_FILE_RAW;
|
||||
}
|
||||
|
||||
qemuDomainSetPrivateDataHooks(caps);
|
||||
|
Loading…
Reference in New Issue
Block a user