diff mbox series

[v2,12/12] libxl_dm: handle the new 6 port ahci controller

Message ID 7556e5b5ae930a7f331293f1a87c1e7f68e8a214.1687215890.git.jupham125@gmail.com (mailing list archive)
State Superseded
Headers show
Series Q35 Support | expand

Commit Message

Joel Upham June 20, 2023, 5:15 p.m. UTC
This patch adds support to allow for 6 emulated devices on a
controller, and handling cdrom drives properly. This is not from the
original patch series.

Signed-off-by: Joel Upham <jupham125@gmail.com>
---
 tools/libs/light/libxl_dm.c | 40 ++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index 17bc2113e1..792dbc4383 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -1937,29 +1937,51 @@  static int libxl__build_device_model_args_new(libxl__gc *gc,
 
             if (disks[i].is_cdrom) {
                 const char *drive_id;
-                if (disk > 4) {
+                if (disk > 4 && b_info->device_model_machine == LIBXL_DEVICE_MODEL_MACHINE_I440) {
                     LOGD(WARN, guest_domid, "Emulated CDROM can be only one of the first 4 disks.\n"
                          "Disk %s will be available via PV drivers but not as an "
                          "emulated disk.",
                          disks[i].vdev);
                     continue;
+                } else if (disk > 6 && 
+                           b_info->device_model_machine == LIBXL_DEVICE_MODEL_MACHINE_Q35) {
+                    LOGD(WARN, guest_domid, "Emulated CDROM can be only one of the first 6 disks.\n"
+                         "Disk %s will be available via PV drivers but not as an "
+                         "emulated disk.",
+                         disks[i].vdev);
+                    continue;
                 }
+		if (b_info->device_model_machine == LIBXL_DEVICE_MODEL_MACHINE_I440) {
+                     drive_id = GCSPRINTF("ide-%i", dev_number);
+                     drive = GCSPRINTF("if=none,readonly=on,id=%s", drive_id);
 
-                drive_id = GCSPRINTF("ide-%i", dev_number);
-                drive = GCSPRINTF("if=none,readonly=on,id=%s", drive_id);
-
-                if (target_path)
-                    drive = libxl__sprintf(gc, "%s,file=%s,format=%s",
-                                           drive, target_path, format);
+                    if (target_path)
+                        drive = libxl__sprintf(gc, "%s,file=%s,format=%s",
+                                               drive, target_path, format);
 
-                flexarray_vappend(dm_args,
+                    flexarray_vappend(dm_args,
                     "-drive", drive,
                     "-device",
                     GCSPRINTF("ide-cd,id=%s,drive=%s,bus=ide.%u,unit=%u",
                               drive_id, drive_id,
                               disk / 2, disk % 2),
                     NULL);
-                continue;
+                   continue;
+                } else {
+                    drive_id = GCSPRINTF("sata-0-%i", dev_number);
+                    drive = GCSPRINTF("if=none,readonly=on,id=%s", drive_id);
+                        if (target_path)
+                            drive = libxl__sprintf(gc, "%s,file=%s,format=%s",
+                                                   drive, target_path, format);
+
+                        flexarray_vappend(dm_args,
+                            "-drive", drive,
+                            "-device",
+                            GCSPRINTF("ide-cd,id=%s,drive=%s,bus=ide.0",
+                                      drive_id, drive_id),
+                            NULL);
+                        continue;
+                }
             } else {
                 /*
                  * Explicit sd disks are passed through as is.