{
virDomainHostdevDefPtr hostdev = NULL;
VIR_AUTOSTRINGLIST tokens = NULL;
+ VIR_AUTOSTRINGLIST options = NULL;
size_t ntokens = 0;
size_t nexttoken = 0;
- char *slotstr;
- char *funcstr;
+ char *str;
+ char *nextstr;
int domain = 0x0;
int bus;
int slot;
int func;
+ virTristateBool filtered = VIR_TRISTATE_BOOL_ABSENT;
- /* pci=['00:1b.0','0000:00:13.0'] */
+ /* pci=['00:1b.0','0000:00:13.0,permissive=1'] */
if (!(tokens = virStringSplitCount(entry, ":", 3, &ntokens)))
return NULL;
return NULL;
nexttoken++;
- /* slot and function */
- slotstr = tokens[nexttoken];
- if (!(funcstr = strchr(slotstr, '.'))) {
+ /* slot, function, and options */
+ str = tokens[nexttoken];
+ if (!(nextstr = strchr(str, '.'))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Malformed PCI address %s"), slotstr);
+ _("Malformed PCI address %s"), str);
return NULL;
}
- *funcstr = '\0';
- funcstr++;
- if (virStrToLong_i(slotstr, NULL, 16, &slot) < 0)
+ *nextstr = '\0';
+ nextstr++;
+ if (virStrToLong_i(str, NULL, 16, &slot) < 0)
return NULL;
- if (virStrToLong_i(funcstr, NULL, 16, &func) < 0)
+ str = nextstr++;
+
+ nextstr = strchr(str, ',');
+ if (nextstr) {
+ *nextstr = '\0';
+ nextstr++;
+ }
+ if (virStrToLong_i(str, NULL, 16, &func) < 0)
return NULL;
+ str = nextstr;
+ if (str && (options = virStringSplit(str, ",", 0))) {
+ size_t i;
+
+ for (i = 0; options[i] != NULL; i++) {
+ char *val;
+
+ if (!(val = strchr(options[i], '='))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Malformed PCI options %s"), str);
+ return NULL;
+ }
+ *val = '\0';
+ val++;
+ if (STREQ(options[i], "permissive")) {
+ int intval;
+
+ /* xl.cfg(5) specifies false as 0 and true as any other numeric value */
+ if (virStrToLong_i(val, NULL, 10, &intval) < 0)
+ return NULL;
+ filtered = intval ? VIR_TRISTATE_BOOL_NO : VIR_TRISTATE_BOOL_YES;
+ }
+ }
+ }
+
if (!(hostdev = virDomainHostdevDefNew()))
return NULL;
hostdev->managed = false;
+ hostdev->writeFiltering = filtered;
hostdev->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI;
hostdev->source.subsys.u.pci.addr.domain = domain;
hostdev->source.subsys.u.pci.addr.bus = bus;
def->hostdevs[i]->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
virConfValuePtr val, tmp;
char *buf;
+ const char *permissive_str = NULL;
- buf = g_strdup_printf("%04x:%02x:%02x.%x",
+ switch (def->hostdevs[i]->writeFiltering) {
+ case VIR_TRISTATE_BOOL_YES:
+ permissive_str = ",permissive=0";
+ break;
+ case VIR_TRISTATE_BOOL_NO:
+ permissive_str = ",permissive=1";
+ break;
+ case VIR_TRISTATE_BOOL_ABSENT:
+ case VIR_TRISTATE_BOOL_LAST:
+ permissive_str = "";
+ break;
+ }
+
+ buf = g_strdup_printf("%04x:%02x:%02x.%x%s",
def->hostdevs[i]->source.subsys.u.pci.addr.domain,
def->hostdevs[i]->source.subsys.u.pci.addr.bus,
def->hostdevs[i]->source.subsys.u.pci.addr.slot,
- def->hostdevs[i]->source.subsys.u.pci.addr.function);
+ def->hostdevs[i]->source.subsys.u.pci.addr.function,
+ permissive_str);
+
if (VIR_ALLOC(val) < 0) {
VIR_FREE(buf);
--- /dev/null
+<domain type='xen'>
+ <name>XenGuest2</name>
+ <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>592896</memory>
+ <currentMemory unit='KiB'>403456</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='xenfv'>hvm</type>
+ <loader type='rom'>/usr/lib/xen/boot/hvmloader</loader>
+ <boot dev='cdrom'/>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <pae/>
+ </features>
+ <clock offset='variable' adjustment='0' basis='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/lib/xen/bin/qemu-system-i386</emulator>
+ <disk type='block' device='disk'>
+ <driver name='phy' type='raw'/>
+ <source dev='/dev/HostVG/XenGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='xenbus' index='0'/>
+ <controller type='ide' index='0'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ <video>
+ <model type='cirrus' vram='8192' heads='1' primary='yes'/>
+ </video>
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <driver name='xen'/>
+ <source>
+ <address domain='0x0000' bus='0x01' slot='0x1a' function='0x1'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <driver name='xen'/>
+ <source writeFiltering='no'>
+ <address domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
+ </source>
+ </hostdev>
+ <memballoon model='xen'/>
+ </devices>
+</domain>