Re: [PATCH] vz: add validation callbacks

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

 



18-Aug-16 14:43, Mikhail Feoktistov пишет:

This patch fixes a bug which occurs when we check a bus and unit number
for a new attached disk. We should do this check in ValidadionCallback,
not in PostParse callback. Because in PostParse we have not initialized
disk->info.addr.drive struct yet.
Move part of code from domainPostParseCallback to domainValidateCallback
and part from devicesPostParseCallback to deviceValidateCallback.
PostParse callbacks are for modification data.
ValidateCallbacks are only for checks.
---
  src/vz/vz_driver.c | 23 +++++++++++++++++++++--
  src/vz/vz_utils.c  |  2 +-
  src/vz/vz_utils.h  |  2 +-
  3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index b1b6d14..e9f9a17 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -232,6 +232,7 @@ vzConnectGetCapabilities(virConnectPtr conn)
      xml = virCapabilitiesFormatXML(privconn->driver->caps);
      return xml;
  }
+

Unrelated

  static int
  vzDomainDefAddDefaultInputDevices(virDomainDefPtr def)
  {
@@ -258,11 +259,19 @@ static int
  vzDomainDefPostParse(virDomainDefPtr def,
                       virCapsPtr caps ATTRIBUTE_UNUSED,
                       unsigned int parseFlags ATTRIBUTE_UNUSED,
-                     void *opaque)
+                     void *opaque ATTRIBUTE_UNUSED)
  {
      if (vzDomainDefAddDefaultInputDevices(def) < 0)
          return -1;
+ return 0;
+}
+
+static int
+vzDomainDefValidate(const virDomainDef *def,
+                    virCapsPtr caps ATTRIBUTE_UNUSED,
+                    void *opaque)
+{
      if (vzCheckUnsupportedControllers(def, opaque) < 0)
          return -1;
@@ -284,6 +293,14 @@ vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
          VIR_STRDUP(dev->data.net->model, "e1000") < 0)
          return -1;
+ return 0;
+}
+
+static int
+vzDomainDeviceDefValidate(const virDomainDeviceDef *dev,
+                          const virDomainDef *def,
+                          void *opaque ATTRIBUTE_UNUSED)
+{
      if (dev->type == VIR_DOMAIN_DEVICE_DISK)
          return vzCheckUnsupportedDisk(def, dev->data.disk, opaque);
      else if (dev->type == VIR_DOMAIN_DEVICE_GRAPHICS)
@@ -299,8 +316,10 @@ static virDomainXMLPrivateDataCallbacks vzDomainXMLPrivateDataCallbacksPtr = {
static virDomainDefParserConfig vzDomainDefParserConfig = {
      .macPrefix = {0x42, 0x1C, 0x00},
-    .devicesPostParseCallback = vzDomainDeviceDefPostParse,
      .domainPostParseCallback = vzDomainDefPostParse,
+    .devicesPostParseCallback = vzDomainDeviceDefPostParse,
+    .domainValidateCallback = vzDomainDefValidate,
+    .deviceValidateCallback = vzDomainDeviceDefValidate,
  };
static vzDriverPtr
diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c
index 312355d..eaf09f2 100644
--- a/src/vz/vz_utils.c
+++ b/src/vz/vz_utils.c
@@ -463,7 +463,7 @@ vzCheckUnsupportedDisk(const virDomainDef *def,
  }
int
-vzCheckUnsupportedControllers(virDomainDefPtr def, vzCapabilitiesPtr vzCaps)
+vzCheckUnsupportedControllers(const virDomainDef *def, vzCapabilitiesPtr vzCaps)
  {
      size_t i, j;
      virDomainControllerDefPtr controller;
diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h
index d033f94..4b407ec 100644
--- a/src/vz/vz_utils.h
+++ b/src/vz/vz_utils.h
@@ -137,7 +137,7 @@ vzCheckUnsupportedDisk(const virDomainDef *def,
                         virDomainDiskDefPtr disk,
                         vzCapabilitiesPtr vzCaps);
  int
-vzCheckUnsupportedControllers(virDomainDefPtr def,
+vzCheckUnsupportedControllers(const virDomainDef *def,
                                vzCapabilitiesPtr vzCaps);
  int
  vzGetDefaultSCSIModel(vzDriverPtr driver,

ACK

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]