How to hot plugin a new vhost-user-blk-pci device to running VM?

Liang Chaojun jesonliang040705 at hotmail.com
Thu May 13 15:11:36 UTC 2021



Thanks Peter for your quickly response. Is there any workaround to do that?As you know we must take care the risk of using latest version in product environment.


Thanks a lot!

> 在 2021年5月13日,22:25,Peter Krempa <pkrempa at redhat.com> 写道:
> 
> On Thu, May 13, 2021 at 15:25:23 +0800, 梁朝军 wrote:
>>   Hi Guy,
>> 
>>   Does  anyone clear how to hot plugin a new vhost-user-blk-pci device to a
>>   running VM?
>> 
>>   Before staring vm , I pass the disk through QEMU command line  like below.
>> 
>>   <qemu:commandline>
>>    <qemu:arg value='-object'/>
>>    <qemu:arg
>>   value='memory-backend-file,id=mem0,size=4G,mem-path=/dev/hugepages,share=on'/>
>>    <qemu:arg value='-numa'/>
>>    <qemu:arg value='node,memdev=mem0'/>
>>    <qemu:arg value='-chardev'/>
>>    <qemu:arg
>>   value='socket,id=spdk_vhost_blk721ea46a-b306-11eb-a280-525400a98761,path=/var/tmp/vhost.721ea46a-b306-11eb-a280-525400a98761,reconnect=1'/>
>>    <qemu:arg value='-device'/>
>>    <qemu:arg
>>   value='vhost-user-blk-pci,chardev=spdk_vhost_blk721ea46a-b306-11eb-a280-525400a98761,bootindex=1,num-queues=4'/>
>>    <qemu:arg value='-chardev'/>
>>    <qemu:arg
>>   value='socket,id=spdk_vhost_blk2f699c58-d222-4629-9fdc-400c3aadc55e,path=/var/tmp/vhost.2f699c58-d222-4629-9fdc-400c3aadc55e,reconnect=1'/>
>>    <qemu:arg value='-device'/>
>>    <qemu:arg
>>   value='vhost-user-blk-pci,chardev=spdk_vhost_blk2f699c58-d222-4629-9fdc-400c3aadc55e,num-queues=4'/>
>>   </qemu:commandline>
>> 
>>   But I don**t know how to live add a vhost-user-blk-pci device on running
>>   VM even with calling attachDevice API now.
> 
> You need to use the proper and supported way to use vhost-user-blk:
> 
>  <disk type='vhostuser' device='disk'>
>    <driver name='qemu' type='raw'/>
>    <source type='unix' path='/tmp/vhost-blk.sock'>
>      <reconnect enabled='yes' timeout='10'/>
>    </source>
>    <target dev='vdf' bus='virtio'/>
>  </disk>
> 
> That works also with attachDevice.
> 
> 
>>   OS: redhat 7.4 Libvirt version: 3.4
> 
> This is obviously way too old for it. You'll need at least libvirt-7.1
> for that.
> 





More information about the libvir-list mailing list