diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm
index 312c5c52c5..53a2cbba38 100644
--- a/perl-xCAT/xCAT/Schema.pm
+++ b/perl-xCAT/xCAT/Schema.pm
@@ -209,7 +209,7 @@ qq{ link,ro - The file is readonly, and will be placed in tmpfs on the booted no
'memory' => 'Megabytes of memory the VM currently should be set to.',
'master' => 'The name of a master image, if any, this virtual machine is linked to. This is generally set by clonevm and indicates the deletion of a master that would invalidate the storage of this virtual machine',
'cpus' => 'Number of CPUs the node should see.',
-'nics' => 'Network configuration parameters. Of the general form [physnet:]interface,.. Generally, interface describes the vlan entity (default for native, tagged for tagged, vl[number] for a specific vlan. physnet is a virtual switch name or port description that is used for some virtualization technologies to construct virtual switches. hypervisor.netmap can map names to hypervisor specific layouts, or the descriptions described there may be used directly here where possible.',
+'nics' => 'Network configuration parameters. Of the general form [physnet:]interface,.. Generally, interface describes the vlan entity (default for native, tagged for tagged, vl[number] for a specific vlan. physnet is a virtual switch name or port description that is used for some virtualization technologies to construct virtual switches. hypervisor.netmap can map names to hypervisor specific layouts, or the descriptions described there may be used directly here where possible. A macvtap device can be created by adding the "|direct" suffix to the interface name.',
'nicmodel' => 'Model of NICs that will be provided to VMs (i.e. e1000, rtl8139, virtio, etc)',
'bootorder' => 'Boot sequence (i.e. net,hd)',
'clockoffset' => 'Whether to have guest RTC synced to "localtime" or "utc" If not populated, xCAT will guess based on the nodetype.os contents.',
diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm
index a7ae8944e3..c589a0fccb 100644
--- a/xCAT-server/lib/xcat/plugins/kvm.pm
+++ b/xCAT-server/lib/xcat/plugins/kvm.pm
@@ -655,6 +655,7 @@ sub build_nicstruct {
my $rethash;
my $nic = shift @nics;
my $type = 'virtio'; #better default fake nic than rtl8139, relevant to most
+ my $nictype = 'bridge';
unless ($nic) {
last; #Don't want to have multiple vnics tied to the same switch
}
@@ -666,9 +667,17 @@ sub build_nicstruct {
if ($nic =~ /=/) {
($nic, $type) = split /=/, $nic, 2;
}
- $rethash->{type} = 'bridge';
+ if ($nic =~ /\|/) {
+ ($nic, $nictype) = split /\|/, $nic, 2;
+ }
+ $rethash->{type} = $nictype;
$rethash->{mac}->{address} = $_;
- $rethash->{source}->{bridge} = $nic;
+ if ($nictype eq 'bridge') {
+ $rethash->{source}->{bridge} = $nic;
+ } elsif ($nictype eq 'direct') {
+ $rethash->{source}->{dev} = $nic;
+ $rethash->{source}->{mode} = 'bridge';
+ }
$rethash->{model}->{type} = $type;
push @rethashes, $rethash;
}
@@ -3082,6 +3091,7 @@ sub fixup_clone_network {
my $bridge = shift @nics;
$bridge =~ s/.*://;
$bridge =~ s/=.*//;
+ $bridge =~ s/\|.*//;
$nicstruct->findnodes("./mac")->[0]->setAttribute("address" => shift @macs);
$nicstruct->findnodes("./source")->[0]->setAttribute("bridge" => $bridge);
}
@@ -3089,6 +3099,7 @@ sub fixup_clone_network {
my $deviceroot = $newnodexml->findnodes("/domain/devices")->[0];
foreach $nic (@nics) { #need more xml to throw at it..
my $type = 'virtio'; #better default fake nic than rtl8139, relevant to most
+ my $nictype = 'bridge';
$nic =~ s/.*://; #the detail of how the bridge was built is of no
#interest to this segment of code
if ($confdata->{vm}->{$node}->[0]->{nicmodel}) {
@@ -3097,7 +3108,16 @@ sub fixup_clone_network {
if ($nic =~ /=/) {
($nic, $type) = split /=/, $nic, 2;
}
- my $xmlsnippet = "";
+ if ($nic =~ /\|/) {
+ ($nic, $nictype) = split /\|/, $nic, 2;
+ }
+ my $xmlsnippet = "";
+ if ($nictype eq 'bridge') {
+ $xmlsnippet .= "";
+ } elsif ($nictype eq 'direct') {
+ $xmlsnippet .= "";
+ }
+ $xmlsnippet .= "";
my $chunk = $parser->parse_balanced_chunk($xmlsnippet);
$deviceroot->appendChild($chunk);
}