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

Re: [libvirt] [PATCH v2 libvirt 1/8] conf: add <model> child element to <filesystem>



On 11.08.2014 16:47, Giuseppe Scrivano wrote:
Signed-off-by: Giuseppe Scrivano <gscrivan redhat com>
---
  src/conf/domain_conf.c | 25 +++++++++++++++++++++++++
  src/conf/domain_conf.h | 11 +++++++++++
  2 files changed, 36 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c7016f3..9252ffa 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -344,6 +344,11 @@ VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
                "ram",
                "bind")

+VIR_ENUM_IMPL(virDomainFSModel, VIR_DOMAIN_FS_MODEL_LAST,
+              "default",
+              "9p",
+              "mtp")
+
  VIR_ENUM_IMPL(virDomainFSDriver, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
                "default",
                "path",
@@ -6458,6 +6463,7 @@ virDomainFSDefParseXML(xmlNodePtr node,
      virDomainFSDefPtr def;
      xmlNodePtr cur, save_node = ctxt->node;
      char *type = NULL;
+    char *model = NULL;
      char *fsdriver = NULL;
      char *source = NULL;
      char *target = NULL;
@@ -6535,6 +6541,9 @@ virDomainFSDefParseXML(xmlNodePtr node,
                      wrpolicy = virXMLPropString(cur, "wrpolicy");
                  if (!format)
                      format = virXMLPropString(cur, "format");
+            } else if (!model &&
+                       xmlStrEqual(cur->name, BAD_CAST "model")) {
+                model = virXMLPropString(cur, "type");

When introducing a new element to the XML it should always go with RNG schema adjustment, docs change and at least one test case.

That is squash 5/8 and 8/8 into this patch.

              }
          }
          cur = cur->next;
@@ -6556,6 +6565,14 @@ virDomainFSDefParseXML(xmlNodePtr node,
          }
      }

+    if (model) {
+        if ((def->model = virDomainFSModelTypeFromString(model)) <= 0) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("unknown model value '%s'"), model);
+            goto error;
+        }
+    }
+
      if (wrpolicy) {
          if ((def->wrpolicy = virDomainFSWrpolicyTypeFromString(wrpolicy)) <= 0) {
              virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -15795,6 +15812,14 @@ virDomainFSDefFormat(virBufferPtr buf,

      switch (def->type) {
      case VIR_DOMAIN_FS_TYPE_MOUNT:
+        virBufferEscapeString(buf, "<source dir='%s'/>\n",
+                              def->src);
+        if (def->model) {
+            virBufferEscapeString(buf, "<model type='%s'/>\n",
+                                  virDomainFSModelTypeToString(def->model));
+        }
+        break;
+
      case VIR_DOMAIN_FS_TYPE_BIND:
          virBufferEscapeString(buf, "<source dir='%s'/>\n",
                                def->src);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ff7d640..d7664e4 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -764,6 +764,15 @@ typedef enum {
      VIR_DOMAIN_FS_TYPE_LAST
  } virDomainFSType;

+/* Filesystem model */
+typedef enum {
+    VIR_DOMAIN_FS_MODEL_DEFAULT = 0,
+    VIR_DOMAIN_FS_MODEL_9P,   /* 9P network filesystem */
+    VIR_DOMAIN_FS_MODEL_MTP,   /* MTP usb filesystem */
+
+    VIR_DOMAIN_FS_MODEL_LAST
+} virDomainFSModel;
+
  /* Filesystem driver type */
  typedef enum {
      VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
@@ -808,6 +817,7 @@ struct _virDomainFSDef {
      virDomainDeviceInfo info;
      unsigned long long space_hard_limit; /* in bytes */
      unsigned long long space_soft_limit; /* in bytes */
+    int model;
  };


@@ -2585,6 +2595,7 @@ VIR_ENUM_DECL(virDomainControllerModelPCI)
  VIR_ENUM_DECL(virDomainControllerModelSCSI)
  VIR_ENUM_DECL(virDomainControllerModelUSB)
  VIR_ENUM_DECL(virDomainFS)
+VIR_ENUM_DECL(virDomainFSModel)
  VIR_ENUM_DECL(virDomainFSDriver)
  VIR_ENUM_DECL(virDomainFSAccessMode)
  VIR_ENUM_DECL(virDomainFSWrpolicy)


And here are some small nits that you should squash in as well:

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c1a9950..d05fabc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6625,6 +6625,7 @@ virDomainFSDefParseXML(xmlNodePtr node,
  cleanup:
     ctxt->node = save_node;
     VIR_FREE(type);
+    VIR_FREE(model);
     VIR_FREE(fsdriver);
     VIR_FREE(target);
     VIR_FREE(source);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index d7664e4..80e0c9a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -767,8 +767,8 @@ typedef enum {
 /* Filesystem model */
 typedef enum {
     VIR_DOMAIN_FS_MODEL_DEFAULT = 0,
-    VIR_DOMAIN_FS_MODEL_9P,   /* 9P network filesystem */
-    VIR_DOMAIN_FS_MODEL_MTP,   /* MTP usb filesystem */
+    VIR_DOMAIN_FS_MODEL_9P,     /* 9P network filesystem */
+    VIR_DOMAIN_FS_MODEL_MTP,    /* MTP usb filesystem */

     VIR_DOMAIN_FS_MODEL_LAST
 } virDomainFSModel;
@@ -817,7 +817,7 @@ struct _virDomainFSDef {
     virDomainDeviceInfo info;
     unsigned long long space_hard_limit; /* in bytes */
     unsigned long long space_soft_limit; /* in bytes */
-    int model;
+    int model; /* enum virDomainFSModel */
 };

Otherwise looking good.

Michal


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