@@ -301,15 +301,19 @@ func (d *QemuKvmDriver) connect(guestDesc *apis.GuestDesc) error {
301301 var sshport = manager .GetSshFreePort ()
302302 defer manager .unsetPort (sshport )
303303
304- //if guestDesc != nil {
305- // for i := range guestDesc.Disks {
306- // disks = append(disks, guestDesc.Disks[i].Path)
307- // }
308- //} else {
309- disks = append (disks , d .imageInfo .Path )
310- //}
311-
312- err := d .qemuArchDriver .StartGuest (sshport , ncpu , memSizeMB , manager .hugepage , manager .hugepageSizeKB , d .imageInfo )
304+ if guestDesc != nil && len (guestDesc .Disks ) > 0 {
305+ for i := range guestDesc .Disks {
306+ disks = append (disks , guestDesc .Disks [i ].Path )
307+ }
308+ } else {
309+ disks = append (disks , d .imageInfo .Path )
310+ }
311+
312+ err := d .qemuArchDriver .StartGuest (
313+ sshport , ncpu , memSizeMB ,
314+ manager .hugepage , manager .hugepageSizeKB ,
315+ d .imageInfo , disks ,
316+ )
313317 if err != nil {
314318 return err
315319 }
@@ -609,7 +613,7 @@ func (d *QemuBaseDriver) CleanGuest() {
609613}
610614
611615func (d * QemuBaseDriver ) startCmds (
612- sshPort , ncpu , memSizeMB int , imageInfo qemuimg.SImageInfo ,
616+ sshPort , ncpu , memSizeMB int , imageInfo qemuimg.SImageInfo , disksPath [] string ,
613617 machineOpts , cdromDeviceOpts , fwOpts , socketPath , initrdPath , kernelPath string ,
614618) string {
615619 cmd := manager .qemuCmd
@@ -644,7 +648,10 @@ func (d *QemuBaseDriver) startCmds(
644648
645649 cmd += __ ("-object %s" , imageInfo .SecretOptions ())
646650 }
647- for i , diskPath := range []string {imageInfo .Path } {
651+ if len (disksPath ) == 0 {
652+ disksPath = []string {imageInfo .Path }
653+ }
654+ for i , diskPath := range disksPath {
648655 diskDrive := __ ("-drive file=%s,if=none,id=drive_%d,cache=none" , diskPath , i )
649656 if imageInfo .Format != qemuimgfmt .RAW && imageInfo .Encrypted () {
650657 diskDrive += ",encrypt.format=luks,encrypt.key-secret=sec0"
@@ -663,7 +670,7 @@ type QemuX86Driver struct {
663670 QemuBaseDriver
664671}
665672
666- func (d * QemuX86Driver ) StartGuest (sshPort , ncpu , memSizeMB int , hugePage bool , pageSizeKB int , imageInfo qemuimg.SImageInfo ) error {
673+ func (d * QemuX86Driver ) StartGuest (sshPort , ncpu , memSizeMB int , hugePage bool , pageSizeKB int , imageInfo qemuimg.SImageInfo , disksPath [] string ) error {
667674 uuid := stringutils .UUID4 ()
668675 socketPath := fmt .Sprintf ("/opt/cloud/host-deployer/hmp_%s.socket" , uuid )
669676 d .pidPath = fmt .Sprintf ("/opt/cloud/host-deployer/%s.pid" , uuid )
@@ -675,6 +682,7 @@ func (d *QemuX86Driver) StartGuest(sshPort, ncpu, memSizeMB int, hugePage bool,
675682 ncpu ,
676683 memSizeMB ,
677684 imageInfo ,
685+ disksPath ,
678686 machineOpts ,
679687 cdromDeviceOpts ,
680688 "" ,
@@ -717,7 +725,7 @@ type QemuARMDriver struct {
717725 QemuBaseDriver
718726}
719727
720- func (d * QemuARMDriver ) StartGuest (sshPort , ncpu , memSizeMB int , hugePage bool , pageSizeKB int , imageInfo qemuimg.SImageInfo ) error {
728+ func (d * QemuARMDriver ) StartGuest (sshPort , ncpu , memSizeMB int , hugePage bool , pageSizeKB int , imageInfo qemuimg.SImageInfo , disksPath [] string ) error {
721729 uuid := stringutils .UUID4 ()
722730 socketPath := fmt .Sprintf ("/opt/cloud/host-deployer/hmp_%s.socket" , uuid )
723731 d .pidPath = fmt .Sprintf ("/opt/cloud/host-deployer/%s.pid" , uuid )
@@ -736,6 +744,7 @@ func (d *QemuARMDriver) StartGuest(sshPort, ncpu, memSizeMB int, hugePage bool,
736744 ncpu ,
737745 memSizeMB ,
738746 imageInfo ,
747+ disksPath ,
739748 machineOpts ,
740749 cdromDeviceOpts ,
741750 fwOpts ,
@@ -775,7 +784,7 @@ func (d *QemuARMDriver) StartGuest(sshPort, ncpu, memSizeMB int, hugePage bool,
775784}
776785
777786type IQemuArchDriver interface {
778- StartGuest (sshPort , ncpu , memSizeMB int , hugePage bool , pageSizeKB int , imageInfo qemuimg.SImageInfo ) error
787+ StartGuest (sshPort , ncpu , memSizeMB int , hugePage bool , pageSizeKB int , imageInfo qemuimg.SImageInfo , disksPath [] string ) error
779788 CleanGuest ()
780789}
781790
0 commit comments