Support virtio-scsi-pci adapter hot-plug
PATCH 1/1 Support virtio-scsi-pci adapter hot-plug
Support the virtio-scsi-pci adapter hot-plug. However, this patch can only make adapter hot-plugable. More effort is needed for LUN hot-plug. Actually, that is the most valuable feature to virtio-scsi.
Following the steps as follows can give an intuitive understanding of this feature after applying the patch to QEMU v1.1.0-rc3.
1, Generate a image file:
qemu-img create -f qcow2 test.img 2G
2, Run qemu with the option -monitor.
3, In the guest, insert necessary modules:
for m in acpiphp pci_hotplug; do sudo modprobe ${m}; done
4, In the qemu monitor,hot add a virtio-scsi-pci adapter:
(qemu)pci_add auto storage if=virtio-scsi-pci
5, Check whether the controller was added:
Guest: lspci
Qemu: (qemu)info qtree
--- blockdev.c | 19 +++++++++++++++---- blockdev.h | 3 ++- hw/pci-hotplug.c | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-)
blockdev.c +15 -4
@@ -31,6 +31,7 @@ static const char *const if_name[IF_COUNT] = { [IF_MTD] = "mtd", [IF_SD] = "sd", [IF_VIRTIO] = "virtio", + [IF_VIRTIO_SCSI] = "virtio-scsi", [IF_XEN] = "xen", };
@@ -436,7 +437,8 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) on_write_error =BLOCK_ERR_STOP_ENOSPC ;if ((buf =qemu_opt_get (opts,"werror" )) !=NULL ) { -if (type !=IF_IDE && type !=IF_SCSI && type !=IF_VIRTIO && type !=IF_NONE ) { +if (type !=IF_IDE && type !=IF_SCSI && type !=IF_VIRTIO && + type !=IF_VIRTIO_SCSI && type !=IF_NONE ) {error_report ("werror is not supported by this bus type" );return NULL ; }
@@ -449,7 +451,8 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) on_read_error =BLOCK_ERR_REPORT ;if ((buf =qemu_opt_get (opts,"rerror" )) !=NULL ) { -if (type !=IF_IDE && type !=IF_VIRTIO && type !=IF_SCSI && type !=IF_NONE ) { +if (type !=IF_IDE && type !=IF_VIRTIO && type !=IF_SCSI && +IF_VIRTIO_SCSI && type !=IF_NONE ) {error_report ("rerror is not supported by this bus type" );return NULL ; }
@@ -461,7 +464,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) }if ((devaddr =qemu_opt_get (opts,"addr" )) !=NULL ) { -if (type !=IF_VIRTIO ) { +if (type !=IF_VIRTIO || type !=IF_VIRTIO_SCSI ) {error_report ("addr is not supported by this bus type" );return NULL ; }
@@ -579,6 +582,14 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)if (devaddr)qemu_opt_set (opts,"addr" , devaddr);break ; +case IF_VIRTIO_SCSI : + opts =qemu_opts_create (qemu_find_opts ("device" ),NULL ,0 ); +qemu_opt_set (opts,"driver" ,"virtio-scsi-pci" ); +qemu_opt_set (opts,"drive" , dinfo->id); +if (devaddr) { +qemu_opt_set (opts,"addr" , devaddr); + } +break ;default :abort (); }
@@ -604,7 +615,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) ro =1 ; }else if (ro ==1 ) {if (type !=IF_SCSI && type !=IF_VIRTIO && type !=IF_FLOPPY && - type !=IF_NONE && type !=IF_PFLASH ) { + type !=IF_NONE && type !=IF_PFLASH &&IF_VIRTIO_SCSI ) {error_report ("readonly not supported by this bus type" ); goto err; }
blockdev.h +2 -1
@@ -22,7 +22,8 @@ void blockdev_auto_del(BlockDriverState *bs);typedef enum {IF_DEFAULT =-1 ,/* for use with drive_add() only */ IF_NONE , -IF_IDE ,IF_SCSI ,IF_FLOPPY ,IF_PFLASH ,IF_MTD ,IF_SD ,IF_VIRTIO ,IF_XEN , +IF_IDE ,IF_SCSI ,IF_FLOPPY ,IF_PFLASH ,IF_MTD ,IF_SD ,IF_VIRTIO ,IF_XEN , +IF_VIRTIO_SCSI ,IF_COUNT }BlockInterfaceType ;
hw/pci-hotplug.c +15 -0
@@ -154,6 +154,8 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, type =IF_SCSI ; else if (!strcmp(buf, "virtio")) { type =IF_VIRTIO ; + } else if (!strcmp(buf, "virtio-scsi")) { + type =IF_VIRTIO_SCSI ; } else {monitor_printf (mon,"type %s not a hotpluggable PCI device.\n" , buf);return NULL ;
@@ -211,6 +213,19 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,if (qdev_init (&dev->qdev) <0 ) dev =NULL ;break ; +case IF_VIRTIO_SCSI : + dev =pci_create (bus, devfn,"virtio-scsi-pci" ); +if (qdev_init (&dev->qdev) <0 ) { + dev =NULL ; + } + +if (dev && dinfo) { +if (scsi_hot_add (mon, &dev->qdev, dinfo,0 ) !=0 ) { +qdev_unplug (&dev->qdev,NULL ); + dev =NULL ; + } + } +break ;default : dev =NULL ; }
Signature · 1 line
1.7.1
Quoted 18 lines · Kelvin Wang
Support the virtio-scsi-pci adapter hot-plug. However, this patch can only make adapter hot-plugable. More effort is needed for LUN hot-plug. Actually, that is the most valuable feature to virtio-scsi.
Following the steps as follows can give an intuitive understanding of this feature after applying the patch to QEMU v1.1.0-rc3.
1, Generate a image file:
qemu-img create -f qcow2 test.img 2G2, Run qemu with the option -monitor.
3, In the guest, insert necessary modules:
for m in acpiphppci_hotplug; do sudo modprobe ${m}; done4, In the qemu monitor,hot add a virtio-scsi-pci adapter:
(qemu)pci_add auto storage if=virtio-scsi-pci
Quoted 6 lines
5, Check whether the controller was added:
Guest: lspci
Qemu: (qemu)info qtreeSigned-off-by Kelvin Wang <[email protected]>Signed-off-by Sheng Liu <[email protected]>
NAK
Do not use pci_add. It is a compatibility command. Use the new style device_add.
Same for if=.
I think you won't need any changes then?
Quoted 11 lines
--- blockdev.c | 19 +++++++++++++++---- blockdev.h | 3 ++- hw/pci-hotplug.c | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-)blockdev.c +0
-0
blockdev.c static const char *const if_name[IF_COUNT] = { · line 34
Quoted 4 lines
blockdev.c +1
-0@@ -31,6 +31,7 @@ static const char *const if_name[IF_COUNT] = { [IF_MTD] = "mtd", [IF_SD] = "sd", [IF_VIRTIO] = "virtio", + [IF_VIRTIO_SCSI] = "virtio-scsi",
weird indentation
blockdev.c static const char *const if_name[IF_COUNT] = { · line 37
Quoted 3 lines
blockdev.c +0
-0[IF_XEN] = "xen", };
I think blockdev is a legacy thing. You are supposed to use the new style device-add. No?
blockdev.c DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) · line 441
Quoted 7 lines
blockdev.c +2
-1@@ -436,7 +437,8 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) on_write_error =BLOCK_ERR_STOP_ENOSPC ;if ((buf =qemu_opt_get (opts,"werror" )) !=NULL ) { -if (type !=IF_IDE && type !=IF_SCSI && type !=IF_VIRTIO && type !=IF_NONE ) { +if (type !=IF_IDE && type !=IF_SCSI && type !=IF_VIRTIO && + type !=IF_VIRTIO_SCSI && type !=IF_NONE ) {
code dupicated here and below. add a function?
blockdev.c DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) · line 455
Quoted 10 lines
blockdev.c +2
-1error_report ("werror is not supported by this bus type" );return NULL ; }@@ -449,7 +451,8 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) on_read_error =BLOCK_ERR_REPORT ;if ((buf =qemu_opt_get (opts,"rerror" )) !=NULL ) { -if (type !=IF_IDE && type !=IF_VIRTIO && type !=IF_SCSI && type !=IF_NONE ) { +if (type !=IF_IDE && type !=IF_VIRTIO && type !=IF_SCSI && +IF_VIRTIO_SCSI && type !=IF_NONE ) {
typo? IF_VIRTIO_SCSI is always != 0 ...
Quoted 41 lines
blockdev.c +10
-2error_report ("rerror is not supported by this bus type" );return NULL ; }@@ -461,7 +464,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) }if ((devaddr =qemu_opt_get (opts,"addr" )) !=NULL ) { -if (type !=IF_VIRTIO ) { +if (type !=IF_VIRTIO || type !=IF_VIRTIO_SCSI ) {error_report ("addr is not supported by this bus type" );return NULL ; }@@ -579,6 +582,14 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)if (devaddr)qemu_opt_set (opts,"addr" , devaddr);break ; +case IF_VIRTIO_SCSI : + opts =qemu_opts_create (qemu_find_opts ("device" ),NULL ,0 ); +qemu_opt_set (opts,"driver" ,"virtio-scsi-pci" ); +qemu_opt_set (opts,"drive" , dinfo->id); +if (devaddr) { +qemu_opt_set (opts,"addr" , devaddr); + } +break ;default :abort (); }@@ -604,7 +615,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) ro =1 ; }else if (ro ==1 ) {if (type !=IF_SCSI && type !=IF_VIRTIO && type !=IF_FLOPPY && - type !=IF_NONE && type !=IF_PFLASH ) { + type !=IF_NONE && type !=IF_PFLASH &&IF_VIRTIO_SCSI ) {error_report ("readonly not supported by this bus type" ); goto err; }blockdev.h +0
-0
blockdev.h void blockdev_auto_del(BlockDriverState *bs); · line 26
Quoted 6 lines
blockdev.h +2
-1@@ -22,7 +22,8 @@ void blockdev_auto_del(BlockDriverState *bs); typedef enum { IF_DEFAULT = -1, /* for use with drive_add() only */ IF_NONE, - IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN, + IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN, + IF_VIRTIO_SCSI,
weird indentation
Quoted 26 lines
blockdev.h +0
-0IF_COUNT } BlockInterfaceType;hw/pci-hotplug.c +8
-0@@ -154,6 +154,8 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, type =IF_SCSI ; else if (!strcmp(buf, "virtio")) { type =IF_VIRTIO ; + } else if (!strcmp(buf, "virtio-scsi")) { + type =IF_VIRTIO_SCSI ; } else {monitor_printf (mon,"type %s not a hotpluggable PCI device.\n" , buf);return NULL ;@@ -211,6 +213,19 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,if (qdev_init (&dev->qdev) <0 ) dev =NULL ;break ; +case IF_VIRTIO_SCSI : + dev =pci_create (bus, devfn,"virtio-scsi-pci" ); +if (qdev_init (&dev->qdev) <0 ) { + dev =NULL ; + } +
hw/pci-hotplug.c static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, · line 231
Quoted 10 lines
hw/pci-hotplug.c +7
-0+if (dev && dinfo) { +if (scsi_hot_add (mon, &dev->qdev, dinfo,0 ) !=0 ) { +qdev_unplug (&dev->qdev,NULL ); + dev =NULL ; + } + } +break ;default : dev =NULL ; }
Here I am sure.
Do not keep adding stuff to pci-hotplug. New devices should use device-add.
Quoted 2 lines
Signature · 1 line
1.7.1
Il 23/05/2012 16:12, Michael S. Tsirkin ha scritto:
Quoted 14 lines
Quoted 8 lines
Quoted 8 lines
2, Run qemu with the option -monitor.
3, In the guest, insert necessary modules:
for m in acpiphppci_hotplug; do sudo modprobe ${m}; done4, In the qemu monitor,hot add a virtio-scsi-pci adapter:
(qemu)pci_add auto storage if=virtio-scsi-pciQuoted 6 lines
Quoted 6 lines
5, Check whether the controller was added:
Guest: lspci
Qemu: (qemu)info qtreeSigned-off-by Kelvin Wang <[email protected]>Signed-off-by Sheng Liu <[email protected]>
Quoted 8 lines
NAK
Do not use
pci_add. It is a compatibility command. Use the new styledevice_add.
Same for if=.I think you won't need any changes then?
You don't. You need to rescan the bus manually in the guest, that's all.
Paolo
Quoted 21 lines · Paolo Bonzini
Il 23/05/2012 16:12, Michael S. Tsirkin ha scritto:
Quoted 20 lines
Quoted 8 lines
Quoted 8 lines
2, Run qemu with the option -monitor.
3, In the guest, insert necessary modules:
for m in acpiphppci_hotplug; do sudo modprobe ${m}; done4, In the qemu monitor,hot add a virtio-scsi-pci adapter:
(qemu)pci_add auto storage if=virtio-scsi-pciQuoted 6 lines
Quoted 6 lines
5, Check whether the controller was added:
Guest: lspci
Qemu: (qemu)info qtreeSigned-off-by Kelvin Wang <[email protected]>Signed-off-by Sheng Liu <[email protected]>NAK
Do not use
pci_add. It is a compatibility command. Use the new styledevice_add.
Same for if=.
Quoted 6 lines
Quoted 2 lines
I think you won't need any changes then?
You don't. You need to rescan the bus manually in the guest, that's all.
Paolo
If the point is to avoid need for manual bus rescans that's good. But please do not touch the legacy commands. If anyone wants to use new devices, new commands drive_add and device_add should be used.
Same for command line flags.
Signature · 1 line
MST
Quoted 25 lines · Michael S. Tsirkin
Quoted 24 lines · Paolo Bonzini
Il 23/05/2012 16:12, Michael S. Tsirkin ha scritto:
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
2, Run qemu with the option -monitor.
3, In the guest, insert necessary modules:
for m in acpiphppci_hotplug; do sudo modprobe ${m}; done4, In the qemu monitor,hot add a virtio-scsi-pci adapter:
(qemu)pci_add auto storage if=virtio-scsi-pciQuoted 6 lines
Quoted 6 lines
5, Check whether the controller was added:
Guest: lspci
Qemu: (qemu)info qtreeSigned-off-by Kelvin Wang <[email protected]>Signed-off-by Sheng Liu <[email protected]>NAK
Do not use
pci_add. It is a compatibility command. Use the new styledevice_add.
Same for if=.I think you won't need any changes then?
Quoted 6 lines
Quoted 3 lines
You don't. You need to rescan the bus manually in the guest, that's all.
Paolo
If the point is to avoid need for manual bus rescans that's good. But please do not touch the legacy commands.
So, may I sent another patch to "avoid need for manual bus rescans"? device_add should be used by users, but another way supplied to users is not necessarily, but always harmless, right?
Quoted 7 lines
If anyone wants to use new devices, new commands
drive_addanddevice_addshould be used.
Same for command line flags.Signature · 1 line
MST
Quoted 26 lines · Kelvin Wang
Quoted 25 lines · Michael S. Tsirkin
Quoted 24 lines · Paolo Bonzini
Il 23/05/2012 16:12, Michael S. Tsirkin ha scritto:
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
2, Run qemu with the option -monitor.
3, In the guest, insert necessary modules:
for m in acpiphppci_hotplug; do sudo modprobe ${m}; done4, In the qemu monitor,hot add a virtio-scsi-pci adapter:
(qemu)pci_add auto storage if=virtio-scsi-pciQuoted 6 lines
Quoted 6 lines
5, Check whether the controller was added:
Guest: lspci
Qemu: (qemu)info qtreeSigned-off-by Kelvin Wang <[email protected]>Signed-off-by Sheng Liu <[email protected]>NAK
Do not use
pci_add. It is a compatibility command. Use the new styledevice_add.
Same for if=.I think you won't need any changes then?
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
You don't. You need to rescan the bus manually in the guest, that's all.
Paolo
If the point is to avoid need for manual bus rescans that's good. But please do not touch the legacy commands.
So, may I sent another patch to "avoid need for manual bus rescans"?
Let's separate bugfixes from adding new commands.
Quoted 2 lines
device_addshould be used by users, but another way supplied to users is not necessarily, but always harmless, right?
No, it has support costs.
Quoted 7 lines
Quoted 7 lines
If anyone wants to use new devices, new commands
drive_addanddevice_addshould be used.
Same for command line flags.Signature · 1 line
MST
Il 24/05/2012 08:31, Kelvin Wang ha scritto:
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
If the point is to avoid need for manual bus rescans that's good. But please do not touch the legacy commands.
So, may I sent another patch to "avoid need for manual bus rescans"?
The virtio spec supports sending events for added and removed devices. I'm pretty sure it will be more than one patch though (at least one in QEMU and one in the kernel :)).
Paolo
Quoted 9 lines · Paolo Bonzini
Il 24/05/2012 08:31, Kelvin Wang ha scritto:
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
If the point is to avoid need for manual bus rescans that's good. But please do not touch the legacy commands.
So, may I sent another patch to "avoid need for manual bus rescans"?
The virtio spec supports sending events for added and removed devices. I'm pretty sure it will be more than one patch though (at least one in QEMU and one in the kernel :)).
OK, thanks. I'll take more efforts to investigate it.
Quoted 3 lines
Paolo
Quoted 26 lines · Kelvin Wang
Quoted 25 lines · Michael S. Tsirkin
Quoted 24 lines · Paolo Bonzini
Il 23/05/2012 16:12, Michael S. Tsirkin ha scritto:
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
2, Run qemu with the option -monitor.
3, In the guest, insert necessary modules:
for m in acpiphppci_hotplug; do sudo modprobe ${m}; done4, In the qemu monitor,hot add a virtio-scsi-pci adapter:
(qemu)pci_add auto storage if=virtio-scsi-pciQuoted 6 lines
Quoted 6 lines
5, Check whether the controller was added:
Guest: lspci
Qemu: (qemu)info qtreeSigned-off-by Kelvin Wang <[email protected]>Signed-off-by Sheng Liu <[email protected]>NAK
Do not use
pci_add. It is a compatibility command. Use the new styledevice_add.
Same for if=.I think you won't need any changes then?
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
You don't. You need to rescan the bus manually in the guest, that's all.
Paolo
If the point is to avoid need for manual bus rescans that's good. But please do not touch the legacy commands.
So, may I sent another patch to "avoid need for manual bus rescans"?
This is LUN hotplug support.
Stefan
Quoted 26 lines · Michael S. Tsirkin
Quoted 18 lines · Kelvin Wang
Support the virtio-scsi-pci adapter hot-plug. However, this patch can only make adapter hot-plugable. More effort is needed for LUN hot-plug. Actually, that is the most valuable feature to virtio-scsi.
Following the steps as follows can give an intuitive understanding of this feature after applying the patch to QEMU v1.1.0-rc3.
1, Generate a image file:
qemu-img create -f qcow2 test.img 2G2, Run qemu with the option -monitor.
3, In the guest, insert necessary modules:
for m in acpiphppci_hotplug; do sudo modprobe ${m}; done4, In the qemu monitor,hot add a virtio-scsi-pci adapter:
(qemu)pci_add auto storage if=virtio-scsi-pciQuoted 6 lines
5, Check whether the controller was added:
Guest: lspci
Qemu: (qemu)info qtreeSigned-off-by Kelvin Wang <[email protected]>Signed-off-by Sheng Liu <[email protected]>
Quoted 7 lines
NAK
Do not use
pci_add. It is a compatibility command. Use the new styledevice_add.
Same for if=.I think you won't need any changes then?
OK, Thanks!
Quoted 41 lines
Quoted 12 lines
--- blockdev.c | 19 +++++++++++++++---- blockdev.h | 3 ++- hw/pci-hotplug.c | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-)blockdev.c +0
-0blockdev.c static const char *const if_name[IF_COUNT] = { · line 34
Quoted 4 lines
blockdev.c +1
-0@@ -31,6 +31,7 @@ static const char *const if_name[IF_COUNT] = { [IF_MTD] = "mtd", [IF_SD] = "sd", [IF_VIRTIO] = "virtio", + [IF_VIRTIO_SCSI] = "virtio-scsi",weird indentation
blockdev.c static const char *const if_name[IF_COUNT] = { · line 37
Quoted 3 lines
blockdev.c +0
-0[IF_XEN] = "xen", };I think blockdev is a legacy thing. You are supposed to use the new style device-add. No?
blockdev.c DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) · line 441
Quoted 7 lines
blockdev.c +2
-1@@ -436,7 +437,8 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) on_write_error =BLOCK_ERR_STOP_ENOSPC ;if ((buf =qemu_opt_get (opts,"werror" )) !=NULL ) { -if (type !=IF_IDE && type !=IF_SCSI && type !=IF_VIRTIO && type !=IF_NONE ) { +if (type !=IF_IDE && type !=IF_SCSI && type !=IF_VIRTIO && + type !=IF_VIRTIO_SCSI && type !=IF_NONE ) {code dupicated here and below. add a function?
Quoted 5 lines
blockdev.c +0
-0error_report ("werror is not supported by this bus type" );return NULL ; }@@ -449,7 +451,8 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
Quoted 7 lines
blockdev.c DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) · line 455
Quoted 5 lines
blockdev.c +2
-1on_read_error =BLOCK_ERR_REPORT ;if ((buf =qemu_opt_get (opts,"rerror" )) !=NULL ) { -if (type !=IF_IDE && type !=IF_VIRTIO && type !=IF_SCSI && type !=IF_NONE ) { +if (type !=IF_IDE && type !=IF_VIRTIO && type !=IF_SCSI && +IF_VIRTIO_SCSI && type !=IF_NONE ) {typo?
IF_VIRTIO_SCSIis always != 0 ...
Ouch, ashamed for my carelessness.
Quoted 95 lines
Quoted 42 lines
blockdev.c +10
-2error_report ("rerror is not supported by this bus type" );return NULL ; }@@ -461,7 +464,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) }if ((devaddr =qemu_opt_get (opts,"addr" )) !=NULL ) { -if (type !=IF_VIRTIO ) { +if (type !=IF_VIRTIO || type !=IF_VIRTIO_SCSI ) {error_report ("addr is not supported by this bus type" );return NULL ; }@@ -579,6 +582,14 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)if (devaddr)qemu_opt_set (opts,"addr" , devaddr);break ; +case IF_VIRTIO_SCSI : + opts =qemu_opts_create (qemu_find_opts ("device" ),NULL ,0 ); +qemu_opt_set (opts,"driver" ,"virtio-scsi-pci" ); +qemu_opt_set (opts,"drive" , dinfo->id); +if (devaddr) { +qemu_opt_set (opts,"addr" , devaddr); + } +break ;default :abort (); }@@ -604,7 +615,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) ro =1 ; }else if (ro ==1 ) {if (type !=IF_SCSI && type !=IF_VIRTIO && type !=IF_FLOPPY && - type !=IF_NONE && type !=IF_PFLASH ) { + type !=IF_NONE && type !=IF_PFLASH &&IF_VIRTIO_SCSI ) {error_report ("readonly not supported by this bus type" ); goto err; }blockdev.h +0
-0blockdev.h void blockdev_auto_del(BlockDriverState *bs); · line 26
Quoted 6 lines
blockdev.h +2
-1@@ -22,7 +22,8 @@ void blockdev_auto_del(BlockDriverState *bs); typedef enum { IF_DEFAULT = -1, /* for use with drive_add() only */ IF_NONE, - IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN, + IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN, + IF_VIRTIO_SCSI,weird indentation
Quoted 26 lines
blockdev.h +0
-0IF_COUNT } BlockInterfaceType;hw/pci-hotplug.c +8
-0@@ -154,6 +154,8 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, type =IF_SCSI ; else if (!strcmp(buf, "virtio")) { type =IF_VIRTIO ; + } else if (!strcmp(buf, "virtio-scsi")) { + type =IF_VIRTIO_SCSI ; } else {monitor_printf (mon,"type %s not a hotpluggable PCI device.\n" , buf);return NULL ;@@ -211,6 +213,19 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,if (qdev_init (&dev->qdev) <0 ) dev =NULL ;break ; +case IF_VIRTIO_SCSI : + dev =pci_create (bus, devfn,"virtio-scsi-pci" ); +if (qdev_init (&dev->qdev) <0 ) { + dev =NULL ; + } +hw/pci-hotplug.c static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, · line 231
Quoted 10 lines
hw/pci-hotplug.c +7
-0+if (dev && dinfo) { +if (scsi_hot_add (mon, &dev->qdev, dinfo,0 ) !=0 ) { +qdev_unplug (&dev->qdev,NULL ); + dev =NULL ; + } + } +break ;default : dev =NULL ; }Here I am sure.
Do not keep adding stuff to pci-hotplug. New devices should use device-add.Quoted 2 lines
Signature · 1 line
1.7.1