用qemu-img访问vhost-user-blk

REF:
Stefan Hajnoczi: Using qemu-img to access vhost-user-blk storage

要求qemu带libblkio支持

root@10-5-245-135:~# /opt/qemu/bin/qemu-system-x86_64 --version
QEMU emulator version 8.2.3
Copyright (c) 2003-2023 Fabrice Bellard and the QEMU Project developers

先用qsd启动一个vhost-user-blk的服务端:
root@10-5-245-135:~# /opt/qemu/bin/qemu-storage-daemon --blockdev file,filename=/var/lib/libvirt/images/test.qcow2,node-name=file   --blockdev qcow2,file=file,node-name=qcow2   --export vhost-user-blk,id=exp0,node-name=qcow2,num-queues=1,writable=on,addr.type=unix,addr.path=/tmp/vhost.sock &

qemu-img通过sock访问vhost-user-blk
root@10-5-245-135:~# /opt/qemu/bin/qemu-img info --image-opts driver=virtio-blk-vhost-user,path=/tmp/vhost.sock,cache.direct=on
image: json:{"driver": "virtio-blk-vhost-user"}
file format: virtio-blk-vhost-user
virtual size: 10 GiB (10737418240 bytes)
disk size: unavailable

还能导出

root@10-5-245-135:~# /opt/qemu/bin/qemu-img convert  --image-opts driver=virtio-blk-vhost-user,path=/tmp/vhost.sock,cache.direct=on  /var/lib/libvirt/images/out.qcow2

或者导出为qcow2:

root@10-5-245-135:~# /opt/qemu/bin/qemu-img convert  -O qcow2  --image-opts driver=virtio-blk-vhost-user,path=/tmp/vhost.sock,cache.direct=on  /var/lib/libvirt/images/out.qcow2



如果vhost-user-blk后端是spdk的话,会报错,后端不支持所要求的协议特性

root@10-5-245-135:~#  /opt/qemu/bin/qemu-img info --image-opts driver=virtio-blk-vhost-user,path=/var/tmp/vhost.1,cache.direct=on
qemu-img: Could not open 'driver=virtio-blk-vhost-user,path=/var/tmp/vhost.1,cache.direct=on': blkio_connect failed: Backend doesn't support required protocol features: Input/output error
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值