[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 4/6] 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.
---
 src/conf/capabilities.h | 4 ++--
 src/conf/domain_conf.c  | 6 ++++--
 src/qemu/qemu_driver.c  | 4 ++--
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 0d56290..99056f8 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -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 *);
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f6ed250..a209d26 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4123,7 +4123,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 &&
@@ -4134,7 +4135,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
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 86cb297..94cda54 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -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);
-- 
1.7.11.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]