[libvirt] [PATCH] libvirt: support block device storage type in virshParseSnapshotDiskspec

Peter Krempa pkrempa at redhat.com
Wed Jun 26 12:42:33 UTC 2019


On Wed, Jun 26, 2019 at 14:05:41 +0800, Liu Dayu wrote:
> virsh snapshot-create-as supports 'file' storage type in --diskspec by default.
> It doesn't support 'block' storage type in the process of virshParseSnapshotDiskspec().
> So if a snapshot on a block device (e.g. LV) was created, the type of current running
> storage source in dumpxml is inconsistent with the actual backend storage source.
> It will check file-system type mismatch failed and return an error message of
> 'Migration without shared storage is unsafe' when VM performs a live migration
> after this snapshot.
> 
> Signed-off-by: Liu Dayu <liu.dayu at zte.com.cn>
> ---
>  tools/virsh-snapshot.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
> index f6bb38b..f9c55e0 100644
> --- a/tools/virsh-snapshot.c
> +++ b/tools/virsh-snapshot.c
> @@ -255,6 +255,8 @@ virshParseSnapshotDiskspec(vshControl *ctl, virBufferPtr buf, const char *str)
>      char **array = NULL;
>      int narray;
>      size_t i;
> +    struct stat st;
> +    int stor_type = VIR_STORAGE_TYPE_NONE;
>  
>      narray = vshStringToArray(str, &array);
>      if (narray <= 0)
> @@ -272,16 +274,29 @@ virshParseSnapshotDiskspec(vshControl *ctl, virBufferPtr buf, const char *str)
>              goto cleanup;
>      }
>  
> +    /* possibly update storage type */
> +    if (file && STRPREFIX(file, "/dev/") && stat(file, &st) == 0 && S_ISBLK(st.st_mode))

virsh has to be able to work remotely so this code will definitely not
be acceptable here.

I think we can only go with adding a "type" field for the diskspec
string which will be either "file" or "block" and do this in that case.

e.g.

--diskspec vda,snapshot=external,driver=qcow2,type=block,file=/dev/whatever
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190626/44bc53bc/attachment-0001.sig>


More information about the libvir-list mailing list