mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
bhyve: auto allocate nmdm console paths
Currently, nmdm console device requires user to specify master and slave path attributes (such as /dev/nmdm0A and /dev/nmdm0B respectively). However, making user find a non-occupied device name might be not convenient, especially for the remote connections. Update the logic to make these attributes optional. In case if not specified, use /dev/nmdm$UUID[AB], where $UUID is a domain's UUID. With this schema it's unlikely nmdm device will clash with other domains or even other non-bhyve nmdm devices. Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
1fc23c885e
commit
b1e6324ca2
@ -170,6 +170,20 @@ bhyveDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
|||||||
dev->data.video->type = VIR_DOMAIN_VIDEO_TYPE_GOP;
|
dev->data.video->type = VIR_DOMAIN_VIDEO_TYPE_GOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
|
||||||
|
dev->data.chr->source->type == VIR_DOMAIN_CHR_TYPE_NMDM) {
|
||||||
|
virDomainChrDefPtr chr = dev->data.chr;
|
||||||
|
|
||||||
|
if (!chr->source->data.nmdm.master) {
|
||||||
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
|
||||||
|
virUUIDFormat(def->uuid, uuidstr);
|
||||||
|
|
||||||
|
chr->source->data.nmdm.master = g_strdup_printf("/dev/nmdm%sA", uuidstr);
|
||||||
|
chr->source->data.nmdm.slave = g_strdup_printf("/dev/nmdm%sB", uuidstr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,17 +559,14 @@ virDomainChrSourceDefValidate(const virDomainChrSourceDef *src_def,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_NMDM:
|
case VIR_DOMAIN_CHR_TYPE_NMDM:
|
||||||
if (!src_def->data.nmdm.master) {
|
if ((src_def->data.nmdm.master && !src_def->data.nmdm.slave) ||
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
(!src_def->data.nmdm.master && src_def->data.nmdm.slave)) {
|
||||||
_("Missing master path attribute for nmdm device"));
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
return -1;
|
_("Should define both master and slave "
|
||||||
|
"path attributes for nmdm device"));
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!src_def->data.nmdm.slave) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Missing slave path attribute for nmdm device"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_TCP:
|
case VIR_DOMAIN_CHR_TYPE_TCP:
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
/usr/sbin/bhyve \
|
||||||
|
-c 1 \
|
||||||
|
-m 214 \
|
||||||
|
-u \
|
||||||
|
-H \
|
||||||
|
-P \
|
||||||
|
-s 0:0,hostbridge \
|
||||||
|
-s 1:0,lpc \
|
||||||
|
-s 2:0,ahci,hd:/tmp/freebsd.img \
|
||||||
|
-s 3:0,virtio-net,faketapdev,mac=52:54:00:b1:42:eb \
|
||||||
|
-l com1,/dev/nmdmdf3be7e7-a104-11e3-aeb0-50e5492bd3dcA bhyve
|
@ -0,0 +1,3 @@
|
|||||||
|
/usr/sbin/bhyveload \
|
||||||
|
-m 214 \
|
||||||
|
-d /tmp/freebsd.img bhyve
|
@ -0,0 +1,24 @@
|
|||||||
|
<domain type='bhyve'>
|
||||||
|
<name>bhyve</name>
|
||||||
|
<uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
|
||||||
|
<memory>219136</memory>
|
||||||
|
<vcpu>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type>hvm</type>
|
||||||
|
</os>
|
||||||
|
<devices>
|
||||||
|
<disk type='file'>
|
||||||
|
<driver name='file' type='raw'/>
|
||||||
|
<source file='/tmp/freebsd.img'/>
|
||||||
|
<target dev='hda' bus='sata'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='2' unit='0'/>
|
||||||
|
</disk>
|
||||||
|
<interface type='bridge'>
|
||||||
|
<mac address='52:54:00:b1:42:eb'/>
|
||||||
|
<model type='virtio'/>
|
||||||
|
<source bridge="virbr0"/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||||
|
</interface>
|
||||||
|
<console type='nmdm'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -177,6 +177,7 @@ mymain(void)
|
|||||||
DO_TEST("macaddr");
|
DO_TEST("macaddr");
|
||||||
DO_TEST("serial");
|
DO_TEST("serial");
|
||||||
DO_TEST("console");
|
DO_TEST("console");
|
||||||
|
DO_TEST("console-master-slave-not-specified");
|
||||||
DO_TEST("grub-defaults");
|
DO_TEST("grub-defaults");
|
||||||
DO_TEST("grub-bootorder");
|
DO_TEST("grub-bootorder");
|
||||||
DO_TEST("grub-bootorder2");
|
DO_TEST("grub-bootorder2");
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
<domain type='bhyve'>
|
||||||
|
<name>bhyve</name>
|
||||||
|
<uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
|
||||||
|
<memory unit='KiB'>219136</memory>
|
||||||
|
<currentMemory unit='KiB'>219136</currentMemory>
|
||||||
|
<vcpu placement='static'>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='x86_64'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<disk type='file' device='disk'>
|
||||||
|
<driver name='file' type='raw'/>
|
||||||
|
<source file='/tmp/freebsd.img'/>
|
||||||
|
<target dev='hda' bus='sata'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='2' unit='0'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='pci' index='0' model='pci-root'/>
|
||||||
|
<controller type='isa' index='0'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='sata' index='0'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<interface type='bridge'>
|
||||||
|
<mac address='52:54:00:b1:42:eb'/>
|
||||||
|
<source bridge='virbr0'/>
|
||||||
|
<model type='virtio'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||||
|
</interface>
|
||||||
|
<serial type='nmdm'>
|
||||||
|
<source master='/dev/nmdmdf3be7e7-a104-11e3-aeb0-50e5492bd3dcA' slave='/dev/nmdmdf3be7e7-a104-11e3-aeb0-50e5492bd3dcB'/>
|
||||||
|
<target port='0'/>
|
||||||
|
</serial>
|
||||||
|
<console type='nmdm'>
|
||||||
|
<source master='/dev/nmdmdf3be7e7-a104-11e3-aeb0-50e5492bd3dcA' slave='/dev/nmdmdf3be7e7-a104-11e3-aeb0-50e5492bd3dcB'/>
|
||||||
|
<target type='serial' port='0'/>
|
||||||
|
</console>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -88,6 +88,7 @@ mymain(void)
|
|||||||
DO_TEST_DIFFERENT("bhyveload-bootorder4");
|
DO_TEST_DIFFERENT("bhyveload-bootorder4");
|
||||||
DO_TEST_DIFFERENT("bhyveload-explicitargs");
|
DO_TEST_DIFFERENT("bhyveload-explicitargs");
|
||||||
DO_TEST_DIFFERENT("console");
|
DO_TEST_DIFFERENT("console");
|
||||||
|
DO_TEST_DIFFERENT("console-master-slave-not-specified");
|
||||||
DO_TEST_DIFFERENT("custom-loader");
|
DO_TEST_DIFFERENT("custom-loader");
|
||||||
DO_TEST_DIFFERENT("disk-cdrom");
|
DO_TEST_DIFFERENT("disk-cdrom");
|
||||||
DO_TEST_DIFFERENT("disk-cdrom-grub");
|
DO_TEST_DIFFERENT("disk-cdrom-grub");
|
||||||
|
Loading…
Reference in New Issue
Block a user