[libvirt PATCHv2 1/2] conf: move filesystem target validation

Ján Tomko posted 2 patches 4 years, 7 months ago
[libvirt PATCHv2 1/2] conf: move filesystem target validation
Posted by Ján Tomko 4 years, 7 months ago
Check the presence of the target in the validation phase.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 src/conf/domain_conf.c     | 6 ------
 src/conf/domain_validate.c | 8 ++++++++
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 139cdfc0a7..f65509d8ec 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9896,12 +9896,6 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt,
         goto error;
     }
 
-    if (target == NULL && !sock) {
-        virReportError(VIR_ERR_NO_TARGET,
-                       source ? "%s" : NULL, source);
-        goto error;
-    }
-
     if (def->type == VIR_DOMAIN_FS_TYPE_RAM) {
         if (!usage) {
             virReportError(VIR_ERR_XML_ERROR, "%s",
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 9422b00964..bba5a85657 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -2036,6 +2036,14 @@ virDomainShmemDefValidate(const virDomainShmemDef *shmem)
 static int
 virDomainFSDefValidate(const virDomainFSDef *fs)
 {
+    if (fs->dst == NULL && !fs->sock) {
+        const char *source = fs->src->path;
+
+        virReportError(VIR_ERR_NO_TARGET,
+                       source ? "%s" : NULL, source);
+        return -1;
+    }
+
     if (fs->info.bootIndex &&
         fs->fsdriver != VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-- 
2.31.1

Re: [libvirt PATCHv2 1/2] conf: move filesystem target validation
Posted by Peter Krempa 4 years, 7 months ago
On Wed, Jun 16, 2021 at 17:09:06 +0200, Ján Tomko wrote:
> Check the presence of the target in the validation phase.
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  src/conf/domain_conf.c     | 6 ------
>  src/conf/domain_validate.c | 8 ++++++++
>  2 files changed, 8 insertions(+), 6 deletions(-)

Reviewed-by: Peter Krempa <pkrempa@redhat.com>