Merge pull request #1163 from SimonFair/VirtioFS-Support

Update VM Share GUI Options
This commit is contained in:
tom mortensen
2022-09-27 12:22:03 -07:00
committed by GitHub
2 changed files with 70 additions and 24 deletions
+40 -21
View File
@@ -660,16 +660,38 @@
}
$sharestr = '';
if (!empty($shares) && $os_type != "windows") {
$memorybacking ="<memoryBacking>
<nosharepages/>
</memoryBacking>" ;
if (!empty($shares)) {
foreach ($shares as $i => $share) {
if (empty($share['source']) || empty($share['target'])) {
if (empty($share['source']) || empty($share['target']) || ($os_type == "windows" && $share["mode"] == "9p")) {
continue;
}
$sharestr .= "<filesystem type='mount' accessmode='passthrough'>
<source dir='" . htmlspecialchars($share['source'], ENT_QUOTES | ENT_XML1) . "'/>
<target dir='" . htmlspecialchars($share['target'], ENT_QUOTES | ENT_XML1) . "'/>
</filesystem>";
if ($share['mode'] == "virtiofs") {
$memorybacking = "<memoryBacking>
<source type='memfd'/>
<access mode='shared'/>
</memoryBacking>" ;
$sharestr .= "<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs' queue='1024' />
<source dir='" . htmlspecialchars($share['source'], ENT_QUOTES | ENT_XML1) . "'/>
<target dir='" . htmlspecialchars($share['target'], ENT_QUOTES | ENT_XML1) . "'/>
<binary path='/usr/libexec/virtiofsd' xattr='on'>
<sandbox mode='chroot'/>
<cache mode='always'/>
<lock posix='on' flock='on'/>
</binary>
</filesystem>" ;
} else {
$sharestr .= "<filesystem type='mount' accessmode='passthrough'>
<source dir='" . htmlspecialchars($share['source'], ENT_QUOTES | ENT_XML1) . "'/>
<target dir='" . htmlspecialchars($share['target'], ENT_QUOTES | ENT_XML1) . "'/>
</filesystem>";
}
}
}
@@ -807,10 +829,8 @@
$metadata
<currentMemory unit='KiB'>$mem</currentMemory>
<memory unit='KiB'>$maxmem</memory>
<memoryBacking>
<nosharepages/>
</memoryBacking>
$cpustr
$memorybacking
<os>
$loader
<type arch='$arch' machine='$machine'>hvm</type>
@@ -1941,21 +1961,20 @@
}
function domain_get_mount_filesystems($domain) {
$xpath = '//domain/devices/filesystem[@type="mount"]';
$sources = $this->get_xpath($domain, $xpath.'/source/@dir', false);
$targets = $this->get_xpath($domain, $xpath.'/target/@dir', false);
$ret = [];
if (!empty($sources)) {
for ($i = 0; $i < $sources['num']; $i++) {
$strXML = $this->domain_get_xml($domain) ;
$xml = new SimpleXMLElement($strXML);
$FS=$xml->xpath('//domain/devices/filesystem[@type="mount"]') ;
foreach($FS as $FSD){
$target=$FSD->target->attributes()->dir ;
$source=$FSD->source->attributes()->dir ;
$mode=$FSD->driver->attributes()->type ;
$ret[] = [
'source' => $sources[$i],
'target' => $targets[$i]
];
}
'source' => $source,
'target' => $target ,
'mode' => $mode
];
}
return $ret;
}
@@ -100,7 +100,8 @@
'shares' => [
[
'source' => '',
'target' => ''
'target' => '',
'mode' => ''
]
]
];
@@ -257,6 +258,7 @@
if (!$arrConfig['template']['os']) {
$arrConfig['template']['os'] = ($arrConfig['domain']['clock']=='localtime' ? 'windows' : 'linux');
}
$os_type = ((empty($arrConfig['template']['os']) || stripos($arrConfig['template']['os'], 'windows') === false) ? 'other' : 'windows');
?>
<link rel="stylesheet" href="<?autov('/plugins/dynamix.vm.manager/scripts/codemirror/lib/codemirror.css')?>">
@@ -800,7 +802,18 @@
$strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : '';
?>
<table class="domain_os other" data-category="Share" data-multiple="true" data-minimum="1" data-index="<?=$i?>" data-prefix="<?=$strLabel?>">
<table data-category="Share" data-multiple="true" data-minimum="1" data-index="<?=$i?>" data-prefix="<?=$strLabel?>">
<tr class="advanced">
<td>_(Unraid Share Mode)_:</td>
<td>
<select name="shares[<?=$i?>][mode]" class="disk_bus narrow">
<?if ($os_type != "windows") echo mk_option($arrShare['mode'], "9p", _('9p Mode'));;?>
<?echo mk_option($arrShare['mode'], "virtiofs", _('Virtiofs Mode'));;?>
</select>
</td>
</tr>
<tr class="advanced">
<td>_(Unraid Share)_:</td>
<td>
@@ -819,9 +832,14 @@
<div class="domain_os other">
<div class="advanced">
<blockquote class="inline_help">
<p>
<b>Unraid Share Mode</b><br>
Used to create a VirtFS mapping to a Linux-based guest. Specify the mode you want to use either 9p or Virtiofs.
</p>
<p>
<b>Unraid Share</b><br>
Used to create a VirtFS mapping to a Linux-based guest. Specify the path on the host here.
Specify the path on the host here.
</p>
<p>
@@ -837,6 +855,15 @@
<?}?>
<script type="text/html" id="tmplShare">
<table class="domain_os other">
<tr class="advanced">
<td>_(Unraid Share Mode)_:</td>
<td>
<select name="shares[{{INDEX}}][mode]" class="disk_bus narrow">
<?if ($os_type != "windows") echo mk_option($arrShare['mode'], "9p", _('9p Mode'));;?>
<?echo mk_option('', "virtiofs", _('Virtiofs Mode'));;?>
</select>
</td>
</tr>
<tr class="advanced">
<td>_(Unraid Share)_:</td>
<td>