Re: [libvirt] [PATCH v2] storage: ZFS support

2014-08-12 Thread Roman Bogorodskiy
  Ján Tomko wrote:

 On 07/26/2014 06:13 PM, Roman Bogorodskiy wrote:
  Implement ZFS storage backend driver. Currently supported
  only on FreeBSD because of ZFS limitations on Linux.
  ---
   configure.ac  |  43 +
   docs/schemas/storagepool.rng  |  20 +++
   docs/storage.html.in  |  34 
   include/libvirt/libvirt.h.in  |   1 +
   po/POTFILES.in|   1 +
   src/Makefile.am   |   8 +
   src/conf/storage_conf.c   |  15 +-
   src/conf/storage_conf.h   |   4 +-
   src/qemu/qemu_conf.c  |   1 +
   src/storage/storage_backend.c |   6 +
   src/storage/storage_backend_zfs.c | 329 
  ++
   src/storage/storage_backend_zfs.h |  29 
   src/storage/storage_driver.c  |   1 +
   tools/virsh-pool.c|   3 +
   14 files changed, 492 insertions(+), 3 deletions(-)
   create mode 100644 src/storage/storage_backend_zfs.c
   create mode 100644 src/storage/storage_backend_zfs.h
 
 ACK

Pushed, thanks!

Roman Bogorodskiy


pgpm4ZQRanFoc.pgp
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2] storage: ZFS support

2014-08-08 Thread Ján Tomko
On 07/26/2014 06:13 PM, Roman Bogorodskiy wrote:
 Implement ZFS storage backend driver. Currently supported
 only on FreeBSD because of ZFS limitations on Linux.
 
 Features supported:
 
  - pool-start, pool-stop
  - pool-info
  - vol-list
  - vol-create / vol-delete
 
 Pool definition looks like that:
 
  pool type='zfs'
   namemyzfspool/name
   source
 nameactualpoolname/name
   /source
  /pool
 
 The 'actualpoolname' value is a name of the pool on the system,
 such as shown by 'zpool list' command. Target makes no sense
 here because volumes path is always /dev/zvol/$poolname/$volname.
 
 Users has to create a pool on his own, this driver doesn't

s/Users/User/

 support pool creation currently.
 
 A volume could be used with Qemu by adding an entry like this:
 
 disk type='volume' device='disk'
   driver name='qemu' type='raw'/
   source pool='myzfspool' volume='vol5'/
   target dev='hdc' bus='ide'/
 /disk
 ---
  configure.ac  |  43 +
  docs/schemas/storagepool.rng  |  20 +++
  docs/storage.html.in  |  34 
  include/libvirt/libvirt.h.in  |   1 +
  po/POTFILES.in|   1 +
  src/Makefile.am   |   8 +
  src/conf/storage_conf.c   |  15 +-
  src/conf/storage_conf.h   |   4 +-
  src/qemu/qemu_conf.c  |   1 +
  src/storage/storage_backend.c |   6 +
  src/storage/storage_backend_zfs.c | 329 
 ++
  src/storage/storage_backend_zfs.h |  29 
  src/storage/storage_driver.c  |   1 +
  tools/virsh-pool.c|   3 +
  14 files changed, 492 insertions(+), 3 deletions(-)
  create mode 100644 src/storage/storage_backend_zfs.c
  create mode 100644 src/storage/storage_backend_zfs.h

ACK

Jan



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2] storage: ZFS support

2014-08-05 Thread Roman Bogorodskiy
  Roman Bogorodskiy wrote:

 Changes from the initial version:
  - Update docs/schemas and docs/storage.html.in with ZFS backend
information
  - Drop StartPool and StopPool that does nothing and therefore
not needed
  - Fix memory leak in 'tokens' variable
  - Fill volume key before creating a volume
  - Use volume's target.path as a key
  - Allow not to specify 'target' for pool because in any case
it should be /dev/zvol/$poolname

Ping?

 Few notes on Linux support:

As for the Linux support I think it doesn't make sense to include it
until there's a release of zfsonlinux available that contains all the
features required, but I'll keep testing on Linux as well to make sure
it'd be easy to add Linux support once the release is available.

Roman Bogorodskiy

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


[libvirt] [PATCH v2] storage: ZFS support

2014-07-26 Thread Roman Bogorodskiy
Changes from the initial version:
 - Update docs/schemas and docs/storage.html.in with ZFS backend
   information
 - Drop StartPool and StopPool that does nothing and therefore
   not needed
 - Fix memory leak in 'tokens' variable
 - Fill volume key before creating a volume
 - Use volume's target.path as a key
 - Allow not to specify 'target' for pool because in any case
   it should be /dev/zvol/$poolname

Few notes on Linux support:

 I've been playing around with http://zfsonlinux.org/. I noticed it 
missed '-H' switch to provide a machine-friendly output and
created a feature request: 

 https://github.com/zfsonlinux/zfs/issues/2522

It was quickly fixed, so I've updated from the git version and moved on.

From that point it worked well and the only thing I had to modify is
not to pass 'volmode' parameter during volume creation (it's freebsd specific
and it could be e.g. just cdev or a FreeBSD geom provider).

So, basically, for the current (limited) feature set the two things
need to be checked on Linux:

 - zpool get support for -H switch
 - zfs volmode support for volume creation

I'm open for suggestions what would be a good way to check it. For the '-H'
thing, I was thinking about calling just 'zpool get -H' in StartPool. If
the error says 'invalid option 'H'' (i.e. check if it just contains 'H'), then
return an error that zfs version is too old. That's fragile, but probably
less fragile than parsing usage that looks like that:

 usage:
get [-pH] all | property[,...] pool ...

As for the 'volmode', it's simple in terms of parsing, because e.g. 'zfs get' 
prints
a nice set of parameters e.g.:

volblocksize NO  YES   512 to 128k, power of 2
volmode YES  YES   default | geom | dev | none
volsize YES   NO   size

So it should not be a problem to check it once and save in some sort of state 
struct
inside of the ZFS backend.


Roman Bogorodskiy (1):
  storage: ZFS support

 configure.ac  |  43 +
 docs/schemas/storagepool.rng  |  20 +++
 docs/storage.html.in  |  34 
 include/libvirt/libvirt.h.in  |   1 +
 po/POTFILES.in|   1 +
 src/Makefile.am   |   8 +
 src/conf/storage_conf.c   |  15 +-
 src/conf/storage_conf.h   |   4 +-
 src/qemu/qemu_conf.c  |   1 +
 src/storage/storage_backend.c |   6 +
 src/storage/storage_backend_zfs.c | 329 ++
 src/storage/storage_backend_zfs.h |  29 
 src/storage/storage_driver.c  |   1 +
 tools/virsh-pool.c|   3 +
 14 files changed, 492 insertions(+), 3 deletions(-)
 create mode 100644 src/storage/storage_backend_zfs.c
 create mode 100644 src/storage/storage_backend_zfs.h

-- 
1.9.0

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


[libvirt] [PATCH v2] storage: ZFS support

2014-07-26 Thread Roman Bogorodskiy
Implement ZFS storage backend driver. Currently supported
only on FreeBSD because of ZFS limitations on Linux.

Features supported:

 - pool-start, pool-stop
 - pool-info
 - vol-list
 - vol-create / vol-delete

Pool definition looks like that:

 pool type='zfs'
  namemyzfspool/name
  source
nameactualpoolname/name
  /source
 /pool

The 'actualpoolname' value is a name of the pool on the system,
such as shown by 'zpool list' command. Target makes no sense
here because volumes path is always /dev/zvol/$poolname/$volname.

Users has to create a pool on his own, this driver doesn't
support pool creation currently.

A volume could be used with Qemu by adding an entry like this:

disk type='volume' device='disk'
  driver name='qemu' type='raw'/
  source pool='myzfspool' volume='vol5'/
  target dev='hdc' bus='ide'/
/disk
---
 configure.ac  |  43 +
 docs/schemas/storagepool.rng  |  20 +++
 docs/storage.html.in  |  34 
 include/libvirt/libvirt.h.in  |   1 +
 po/POTFILES.in|   1 +
 src/Makefile.am   |   8 +
 src/conf/storage_conf.c   |  15 +-
 src/conf/storage_conf.h   |   4 +-
 src/qemu/qemu_conf.c  |   1 +
 src/storage/storage_backend.c |   6 +
 src/storage/storage_backend_zfs.c | 329 ++
 src/storage/storage_backend_zfs.h |  29 
 src/storage/storage_driver.c  |   1 +
 tools/virsh-pool.c|   3 +
 14 files changed, 492 insertions(+), 3 deletions(-)
 create mode 100644 src/storage/storage_backend_zfs.c
 create mode 100644 src/storage/storage_backend_zfs.h

diff --git a/configure.ac b/configure.ac
index f37c716..7e46460 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1734,6 +1734,10 @@ AC_ARG_WITH([storage-gluster],
   [AS_HELP_STRING([--with-storage-gluster],
 [with Gluster backend for the storage driver @:@default=check@:@])],
   [],[with_storage_gluster=check])
+AC_ARG_WITH([storage-zfs],
+  [AS_HELP_STRING([--with-storage-zfs],
+[with ZFS backend for the storage driver @:@default=check@:@])],
+  [],[with_storage_zfs=check])
 
 if test $with_libvirtd = no; then
   with_storage_dir=no
@@ -1746,6 +1750,7 @@ if test $with_libvirtd = no; then
   with_storage_rbd=no
   with_storage_sheepdog=no
   with_storage_gluster=no
+  with_storage_zfs=no
 fi
 if test $with_storage_dir = yes ; then
   AC_DEFINE_UNQUOTED([WITH_STORAGE_DIR], 1, [whether directory backend for 
storage driver is enabled])
@@ -1963,6 +1968,43 @@ if test $with_storage_gluster = yes; then
 fi
 AM_CONDITIONAL([WITH_STORAGE_GLUSTER], [test $with_storage_gluster = yes])
 
+if test $with_storage_zfs = check; then
+with_storage_zfs=$with_freebsd
+fi
+
+if test $with_storage_zfs = yes  test $with_freebsd = no; then
+AC_MSG_ERROR([The ZFS storage driver can be enabled on FreeBSD only.])
+fi
+
+if test $with_storage_zfs = yes ||
+   test $with_storage_zfs = check; then
+  AC_PATH_PROG([ZFS], [zfs], [], [$PATH:/sbin:/usr/sbin])
+  AC_PATH_PROG([ZPOOL], [zpool], [], [$PATH:/sbin:/usr/sbin])
+
+  if test $with_storage_zfs = yes; then
+if test -z $ZFS || test -z $ZPOOL; then
+  AC_MSG_ERROR([We need zfs and zpool for ZFS storage driver])
+fi
+  else
+if test -z $ZFS || test -z $ZPOOL; then
+  with_storage_zfs=no
+fi
+
+if test $with_storage_zfs = check; then
+  with_storage_zfs=yes
+fi
+  fi
+
+  if test $with_storage_zfs = yes; then
+AC_DEFINE_UNQUOTED([WITH_STORAGE_ZFS], 1,
+  [whether ZFS backend for storage driver is enabled])
+AC_DEFINE_UNQUOTED([ZFS], [$ZFS], [Location of zfs program])
+AC_DEFINE_UNQUOTED([ZPOOL], [$ZPOOL], [Location of zpool program])
+  fi
+fi
+AM_CONDITIONAL([WITH_STORAGE_ZFS],
+  [test $with_storage_zfs = yes])
+
 if test $with_storage_fs = yes ||
test $with_storage_gluster = yes; then
   AC_PATH_PROG([GLUSTER_CLI], [gluster], [], [$PATH:/sbin:/usr/sbin])
@@ -2806,6 +2848,7 @@ AC_MSG_NOTICE([Disk: $with_storage_disk])
 AC_MSG_NOTICE([ RBD: $with_storage_rbd])
 AC_MSG_NOTICE([Sheepdog: $with_storage_sheepdog])
 AC_MSG_NOTICE([ Gluster: $with_storage_gluster])
+AC_MSG_NOTICE([ ZFS: $with_storage_zfs])
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Security Drivers])
 AC_MSG_NOTICE([])
diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index b2d1473..908cc11 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -22,6 +22,7 @@
 ref name='poolrbd'/
 ref name='poolsheepdog'/
 ref name='poolgluster'/
+ref name='poolzfs'/
   /choice
 /element
   /define
@@ -157,6 +158,17 @@
 /interleave
   /define
 
+  define name='poolzfs'
+attribute name='type'
+  valuezfs/value
+/attribute
+interleave
+  ref name='commonmetadata'/
+  ref name='sizing'/
+  ref name='sourcezfs'/
+/interleave
+  /define
+
   define name='sourceinfovendor'
 interleave
   optional
@@