Re: [PATCH v2] Introduce <driver> under <filesystem> to support open-by-handle.

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

 



On Mon, Oct 10, 2011 at 05:18:53PM +0530, Harsh Prateek Bora wrote:
> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
> index 492a41d..3937393 100644
> --- a/docs/schemas/domaincommon.rng
> +++ b/docs/schemas/domaincommon.rng
> @@ -1025,6 +1025,15 @@
>        </choice>
>        <optional>
>          <ref name="address"/>
> +        <element name="driver">
> +          <attribute name="type">
> +          <choice>
> +            <value>path</value>
> +            <value>handle</value>
> +          </choice>
> +          </attribute>
> +          <empty/>
> +        </element>
>          <attribute name="accessmode">
>          <choice>
>            <value>passthrough</value>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index a537251..ede1f01 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -238,6 +238,11 @@ VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
>                "file",
>                "template")
>  
> +VIR_ENUM_IMPL(virDomainFSDriverType, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
> +              "default",
> +              "path",
> +              "handle")
> +
>  VIR_ENUM_IMPL(virDomainFSAccessMode, VIR_DOMAIN_FS_ACCESSMODE_LAST,
>                "passthrough",
>                "mapped",
> @@ -2828,6 +2833,7 @@ virDomainFSDefParseXML(xmlNodePtr node,
>      virDomainFSDefPtr def;
>      xmlNodePtr cur;
>      char *type = NULL;
> +    char *fsdriver = NULL;
>      char *source = NULL;
>      char *target = NULL;
>      char *accessmode = NULL;
> @@ -2878,11 +2884,23 @@ virDomainFSDefParseXML(xmlNodePtr node,
>                  target = virXMLPropString(cur, "dir");
>              } else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
>                  def->readonly = 1;
> +            } else if ((fsdriver == NULL) && (xmlStrEqual(cur->name, BAD_CAST "driver"))) {
> +                fsdriver = virXMLPropString(cur, "type");
>              }
>          }
>          cur = cur->next;
>      }
>  
> +    if (fsdriver) {
> +        if ((def->fsdriver = virDomainFSDriverTypeTypeFromString(fsdriver)) < 0) {
> +            virDomainReportError(VIR_ERR_INTERNAL_ERROR,
> +                                 _("unknown fs driver type '%s'"), fsdriver);
> +            goto error;
> +        }
> +    } else {
> +        def->fsdriver = VIR_DOMAIN_FS_DRIVER_TYPE_PATH;
> +    }
> +
>      if (source == NULL) {
>          virDomainReportError(VIR_ERR_NO_SOURCE,
>                               target ? "%s" : NULL, target);
> @@ -2905,6 +2923,7 @@ virDomainFSDefParseXML(xmlNodePtr node,
>  
>  cleanup:
>      VIR_FREE(type);
> +    VIR_FREE(fsdriver);
>      VIR_FREE(target);
>      VIR_FREE(source);
>      VIR_FREE(accessmode);
> @@ -9351,6 +9370,7 @@ virDomainFSDefFormat(virBufferPtr buf,
>  {
>      const char *type = virDomainFSTypeToString(def->type);
>      const char *accessmode = virDomainFSAccessModeTypeToString(def->accessmode);
> +    const char *fsdriver = virDomainFSDriverTypeTypeToString(def->fsdriver);
>  
>      if (!type) {
>          virDomainReportError(VIR_ERR_INTERNAL_ERROR,
> @@ -9369,6 +9389,10 @@ virDomainFSDefFormat(virBufferPtr buf,
>                        "    <filesystem type='%s' accessmode='%s'>\n",
>                        type, accessmode);
>  
> +    if (def->fsdriver) {
> +        virBufferAsprintf(buf, "      <driver type='%s'/>\n", fsdriver);
> +    }
> +
>      if (def->src) {
>          switch (def->type) {
>          case VIR_DOMAIN_FS_TYPE_MOUNT:
> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> index e07fd2f..4f8993b 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -368,6 +368,15 @@ enum virDomainFSType {
>      VIR_DOMAIN_FS_TYPE_LAST
>  };
>  
> +/* Filesystem driver type */
> +enum virDomainFSDriverType {
> +    VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
> +    VIR_DOMAIN_FS_DRIVER_TYPE_PATH,
> +    VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE,
> +
> +    VIR_DOMAIN_FS_DRIVER_TYPE_LAST
> +};
> +
>  /* Filesystem mount access mode  */
>  enum virDomainFSAccessMode {
>      VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH,
> @@ -381,6 +390,7 @@ typedef struct _virDomainFSDef virDomainFSDef;
>  typedef virDomainFSDef *virDomainFSDefPtr;
>  struct _virDomainFSDef {
>      int type;
> +    int fsdriver;
>      int accessmode;
>      char *src;
>      char *dst;
> @@ -1856,6 +1866,7 @@ VIR_ENUM_DECL(virDomainController)
>  VIR_ENUM_DECL(virDomainControllerModelSCSI)
>  VIR_ENUM_DECL(virDomainControllerModelUSB)
>  VIR_ENUM_DECL(virDomainFS)
> +VIR_ENUM_DECL(virDomainFSDriverType)
>  VIR_ENUM_DECL(virDomainFSAccessMode)
>  VIR_ENUM_DECL(virDomainNet)
>  VIR_ENUM_DECL(virDomainNetBackend)
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index cf99f89..112610b 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -1818,7 +1818,12 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
>          goto error;
>      }
>  
> -    virBufferAddLit(&opt, "local");
> +    if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_PATH) {
> +        virBufferAddLit(&opt, "local");
> +    } else if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE) {
> +        virBufferAddLit(&opt, "handle");
> +    }
> +

I don't think QEMU allows you to omit the driver type, and we need todo
error reporting for unsupported values (in case we add more types for
other HVs like LXC). Using the enums would take care of both these issues

eg, 

In global scope:

    VIR_ENUM_DECL(qemuDomainFSDriver)
    VIR_ENUM_IMPL(qemuDomainFSDriver, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
                  "local", "local", "handle");

In the function scope

      const char *driver = qemuDomainFSDriverTypeToString(fs->fsdriver);
      if (!driver) {
        qemuReportError(VIR_ERR_CONFIG_UNSUPPORTEd, "%s",
                        _("Filesystem driver type not supported"));
        goto cleanup;
      }
      virBufferAddLit(&buf, driver, -1);
 

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
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]