Skip to content

Commit

Permalink
OS-6926 add support to bhyve zones for ahci disks
Browse files Browse the repository at this point in the history
Reviewed by: Mike Gerdts <mike.gerdts@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: John Levon <john.levon@joyent.com>
Approved by: John Levon <john.levon@joyent.com>
  • Loading branch information
sjorge authored and pfmooney committed May 10, 2018
1 parent d5480cf commit c0ca16f
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions usr/src/lib/brand/bhyve/zone/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ add_ram(int *argc, char **argv)
}

static int
add_disk(char *disk, char *path, char *slotconf, size_t slotconf_len)
add_disk(char *disk, char *path, const char *model, char *slotconf,
size_t slotconf_len)
{
static char *boot = NULL;
static int next_cd = 0;
static int next_other = 0;
const char *emulation = "virtio-blk";
int pcislot;
int pcifn;

Expand All @@ -198,8 +200,22 @@ add_disk(char *disk, char *path, char *slotconf, size_t slotconf_len)
next_other++;
}

if (snprintf(slotconf, slotconf_len, "%d:%d,virtio-blk,%s",
pcislot, pcifn, path) >= slotconf_len) {

if (strcmp(model, "virtio") == 0) {
emulation = "virtio-blk";
} else if (strcmp(model, "ahci") == 0) {
if (is_env_true("device", disk, "cdrom")) {
emulation = "ahci-cd";
} else {
emulation = "ahci-hd";
}
} else {
(void) printf("Error: unknown disk model '%s'\n", model);
return (-1);
}

if (snprintf(slotconf, slotconf_len, "%d:%d,%s,%s",
pcislot, pcifn, emulation, path) >= slotconf_len) {
(void) printf("Error: disk path '%s' too long\n", path);
return (-1);
}
Expand Down Expand Up @@ -297,15 +313,12 @@ add_devices(int *argc, char **argv)
return (-1);
}

if (strcmp(model, "virtio") == 0) {
ret = add_disk(dev, path, slotconf, sizeof (slotconf));
} else if (strcmp(model, "passthru") == 0) {
if (strcmp(model, "passthru") == 0) {
ret = add_ppt(argc, argv, dev, path, slotconf,
sizeof (slotconf));
} else {
(void) printf("Error: device %s has invalid model: "
"%s\n", dev, model);
ret = -1;
ret = add_disk(dev, path, model, slotconf,
sizeof (slotconf));
}

if (ret != 0)
Expand Down

0 comments on commit c0ca16f

Please sign in to comment.