[libvirt] [PATCH go-xml] Support for filesystem devices

Ryan Goodfellow rgoodfel at isi.edu
Fri Apr 21 04:56:59 UTC 2017


Hi Folks,

Any thoughts on this? This is my first time posting to this list, not sure
if I should direct the patch at someone in particular.

On Tue, Apr 18, 2017 at 3:01 PM, Ryan Goodfellow <rgoodfel at isi.edu> wrote:

> This commit adds filesystem device support. A new family of types
> DomainFilesystem* are introduced and plumbed into the DomainDeviceList
> struct.
>
> Testing has also been included.
> ---
>  domain.go      | 40 ++++++++++++++++++++++++++++++++++++++++
>  domain_test.go | 55 ++++++++++++++++++++++++++++++
> +++++++++++++++++++++++++
>  2 files changed, 95 insertions(+)
>
> diff --git a/domain.go b/domain.go
> index 307c71c..cccd9a6 100644
> --- a/domain.go
> +++ b/domain.go
> @@ -81,6 +81,45 @@ type DomainDisk struct {
>         Target   *DomainDiskTarget `xml:"target"`
>  }
>
> +type DomainFilesystemDriver struct {
> +       Type     string `xml:"type,attr"`
> +       Name     string `xml:"name,attr,omitempty"`
> +       WRPolicy string `xml:"wrpolicy,attr,omitempty"`
> +}
> +
> +type DomainFilesystemSource struct {
> +       Dir  string `xml:"dir,attr,omitempty"`
> +       File string `xml:"file,attr,omitempty"`
> +}
> +
> +type DomainFilesystemTarget struct {
> +       Dir string `xml:"dir,attr"`
> +}
> +
> +type DomainFilesystemReadOnly struct {
> +}
> +
> +type DomainFilesystemSpaceHardLimit struct {
> +       Value int    `xml:",chardata"`
> +       Unit  string `xml:"unit,attr,omitempty"`
> +}
> +
> +type DomainFilesystemSpaceSoftLimit struct {
> +       Value int    `xml:",chardata"`
> +       Unit  string `xml:"unit,attr,omitempty"`
> +}
> +
> +type DomainFilesystem struct {
> +       Type           string                          `xml:"type,attr"`
> +       AccessMode     string
> `xml:"accessmode,attr"`
> +       Driver         *DomainFilesystemDriver         `xml:"driver"`
> +       Source         *DomainFilesystemSource         `xml:"source"`
> +       Target         *DomainFilesystemTarget         `xml:"target"`
> +       ReadOnly       *DomainFilesystemReadOnly       `xml:"readonly"`
> +       SpaceHardLimit *DomainFilesystemSpaceHardLimit
> `xml:"space_hard_limit"`
> +       SpaceSoftLimit *DomainFilesystemSpaceSoftLimit
> `xml:"space_soft_limit"`
> +}
> +
>  type DomainInterfaceMAC struct {
>         Address string `xml:"address,attr"`
>  }
> @@ -212,6 +251,7 @@ type DomainVideo struct {
>  type DomainDeviceList struct {
>         Controllers []DomainController `xml:"controller"`
>         Disks       []DomainDisk       `xml:"disk"`
> +       Filesystems []DomainFilesystem `xml:"filesystem"`
>         Interfaces  []DomainInterface  `xml:"interface"`
>         Serials     []DomainChardev    `xml:"serial"`
>         Consoles    []DomainChardev    `xml:"console"`
> diff --git a/domain_test.go b/domain_test.go
> index e5347ea..06d585c 100644
> --- a/domain_test.go
> +++ b/domain_test.go
> @@ -690,6 +690,61 @@ var domainTestData = []struct {
>                         `</domain>`,
>                 },
>         },
> +       {
> +               Object: &Domain{
> +                       Type: "kvm",
> +                       Name: "test",
> +                       Devices: &DomainDeviceList{
> +                               Filesystems: []DomainFilesystem{
> +                                       DomainFilesystem{
> +                                               Type:       "mount",
> +                                               AccessMode: "mapped",
> +                                               Driver:
> &DomainFilesystemDriver{
> +                                                       Type:     "path",
> +                                                       WRPolicy:
> "immediate",
> +                                               },
> +                                               Source:
> &DomainFilesystemSource{
> +                                                       Dir:
> "/home/user/test",
> +                                               },
> +                                               Target:
> &DomainFilesystemTarget{
> +                                                       Dir:
> "user-test-mount",
> +                                               },
> +                                       },
> +                                       DomainFilesystem{
> +                                               Type:       "file",
> +                                               AccessMode: "passthrough",
> +                                               Driver:
> &DomainFilesystemDriver{
> +                                                       Name: "loop",
> +                                                       Type: "raw",
> +                                               },
> +                                               Source:
> &DomainFilesystemSource{
> +                                                       File:
> "/home/user/test.img",
> +                                               },
> +                                               Target:
> &DomainFilesystemTarget{
> +                                                       Dir:
> "user-file-test-mount",
> +                                               },
> +                                       },
> +                               },
> +                       },
> +               },
> +               Expected: []string{
> +                       `<domain type="kvm">`,
> +                       `  <name>test</name>`,
> +                       `  <devices>`,
> +                       `    <filesystem type="mount"
> accessmode="mapped">`,
> +                       `      <driver type="path"
> wrpolicy="immediate"></driver>`,
> +                       `      <source dir="/home/user/test"></source>`,
> +                       `      <target dir="user-test-mount"></target>`,
> +                       `    </filesystem>`,
> +                       `    <filesystem type="file"
> accessmode="passthrough">`,
> +                       `      <driver type="raw" name="loop"></driver>`,
> +                       `      <source file="/home/user/test.img"></
> source>`,
> +                       `      <target dir="user-file-test-mount"></
> target>`,
> +                       `    </filesystem>`,
> +                       `  </devices>`,
> +                       `</domain>`,
> +               },
> +       },
>  }
>
>  func TestDomain(t *testing.T) {
> --
> 2.11.0
>
>


-- 
*ry**@isi*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170420/a08b2f8c/attachment-0001.htm>


More information about the libvir-list mailing list