提交 4dc5d8f1 编写于 作者: Y Yohan BELLEGUIC 提交者: Daniel P. Berrange

Add vbox_snapshot_conf struct

This structure contains the data to be saved in the VirtualBox XML file
and can be manipulated with severals exposed functions.
The structure is created by vboxSnapshotLoadVboxFile taking the
machine XML file.
It also can rewrite the XML by using vboxSnapshotSaveVboxFile.
上级 538ee933
......@@ -212,6 +212,7 @@ src/util/virxml.c
src/vbox/vbox_MSCOMGlue.c
src/vbox/vbox_XPCOMCGlue.c
src/vbox/vbox_driver.c
src/vbox/vbox_snapshot_conf.c
src/vbox/vbox_tmpl.c
src/vmware/vmware_conf.c
src/vmware/vmware_driver.c
......
......@@ -663,6 +663,7 @@ VMWARE_DRIVER_SOURCES = \
VBOX_DRIVER_SOURCES = \
vbox/vbox_glue.c vbox/vbox_glue.h \
vbox/vbox_driver.c vbox/vbox_driver.h \
vbox/vbox_snapshot_conf.c vbox/vbox_snapshot_conf.h \
vbox/vbox_V2_2.c vbox/vbox_CAPI_v2_2.h \
vbox/vbox_V3_0.c vbox/vbox_CAPI_v3_0.h \
vbox/vbox_V3_1.c vbox/vbox_CAPI_v3_1.h \
......
此差异已折叠。
/*
* Copyright 2014, diateam (www.diateam.net)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef VBOX_SNAPSHOT_CONF_H
# define VBOX_SNAPSHOT_CONF_H
# include "internal.h"
# define VBOX_UUID_REGEX "([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})"
/*Stores VirtualBox xml hard disk information
A hard disk can have a parent and children*/
typedef struct _virVBoxSnapshotConfHardDisk virVBoxSnapshotConfHardDisk;
typedef virVBoxSnapshotConfHardDisk *virVBoxSnapshotConfHardDiskPtr;
struct _virVBoxSnapshotConfHardDisk {
virVBoxSnapshotConfHardDiskPtr parent;
char *uuid;
char *location;
char *format;
char *type;
size_t nchildren;
virVBoxSnapshotConfHardDiskPtr *children;
};
/*Stores Virtualbox xml media registry information
We separate disks from other media to manipulate them*/
typedef struct _virVBoxSnapshotConfMediaRegistry virVBoxSnapshotConfMediaRegistry;
typedef virVBoxSnapshotConfMediaRegistry *virVBoxSnapshotConfMediaRegistryPtr;
struct _virVBoxSnapshotConfMediaRegistry {
size_t ndisks;
virVBoxSnapshotConfHardDiskPtr *disks;
size_t notherMedia;
char **otherMedia;
};
/*Stores VirtualBox xml snapshot information
A snapshot can have a parent and children*/
typedef struct _virVBoxSnapshotConfSnapshot virVBoxSnapshotConfSnapshot;
typedef virVBoxSnapshotConfSnapshot *virVBoxSnapshotConfSnapshotPtr;
struct _virVBoxSnapshotConfSnapshot {
virVBoxSnapshotConfSnapshotPtr parent;
char *uuid;
char *name;
char *timeStamp;
char *description;
char *hardware;
char *storageController;
size_t nchildren;
virVBoxSnapshotConfSnapshotPtr *children;
};
/*Stores VirtualBox xml Machine information*/
typedef struct _virVBoxSnapshotConfMachine virVBoxSnapshotConfMachine;
typedef virVBoxSnapshotConfMachine *virVBoxSnapshotConfMachinePtr;
struct _virVBoxSnapshotConfMachine {
char *uuid;
char *name;
char *currentSnapshot;
char *snapshotFolder;
int currentStateModified;
char *lastStateChange;
virVBoxSnapshotConfMediaRegistryPtr mediaRegistry;
char *hardware;
char *extraData;
virVBoxSnapshotConfSnapshotPtr snapshot;
char *storageController;
};
void
virVboxSnapshotConfHardDiskFree(virVBoxSnapshotConfHardDiskPtr disk);
void
virVBoxSnapshotConfMediaRegistryFree(virVBoxSnapshotConfMediaRegistryPtr mediaRegistry);
void
virVBoxSnapshotConfSnapshotFree(virVBoxSnapshotConfSnapshotPtr snapshot);
void
virVBoxSnapshotConfMachineFree(virVBoxSnapshotConfMachinePtr machine);
virVBoxSnapshotConfMachinePtr
virVBoxSnapshotConfLoadVboxFile(const char *filePath,
const char *machineLocation);
int
virVBoxSnapshotConfAddSnapshotToXmlMachine(virVBoxSnapshotConfSnapshotPtr snapshot,
virVBoxSnapshotConfMachinePtr machine,
const char *snapshotParentName);
int
virVBoxSnapshotConfAddHardDiskToMediaRegistry(virVBoxSnapshotConfHardDiskPtr hardDisk,
virVBoxSnapshotConfMediaRegistryPtr mediaRegistry,
const char *parentHardDiskId);
int
virVBoxSnapshotConfRemoveSnapshot(virVBoxSnapshotConfMachinePtr machine,
const char *snapshotName);
int
virVBoxSnapshotConfRemoveHardDisk(virVBoxSnapshotConfMediaRegistryPtr mediaRegistry,
const char *uuid);
int
virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachinePtr machine,
const char *filePath);
int
virVBoxSnapshotConfIsCurrentSnapshot(virVBoxSnapshotConfMachinePtr machine,
const char *snapshotName);
int
virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(const char *filePath,
char ***realReadWriteDisksPath);
int
virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(const char *filePath,
char ***realReadOnlyDisksPath);
const char *
virVBoxSnapshotConfHardDiskUuidByLocation(virVBoxSnapshotConfMachinePtr machine,
const char *location);
size_t
virVBoxSnapshotConfDiskListToOpen(virVBoxSnapshotConfMachinePtr machine,
virVBoxSnapshotConfHardDiskPtr **hardDiskToOpen,
const char *location);
int
virVBoxSnapshotConfRemoveFakeDisks(virVBoxSnapshotConfMachinePtr machine);
int
virVBoxSnapshotConfDiskIsInMediaRegistry(virVBoxSnapshotConfMachinePtr machine,
const char *location);
virVBoxSnapshotConfHardDiskPtr
virVBoxSnapshotConfHardDiskPtrByLocation(virVBoxSnapshotConfMachinePtr machine,
const char *location);
virVBoxSnapshotConfSnapshotPtr
virVBoxSnapshotConfSnapshotByName(virVBoxSnapshotConfSnapshotPtr snapshot,
const char *snapshotName);
#endif /*VBOX_SNAPSHOT_CONF_H*/
......@@ -125,6 +125,7 @@ EXTRA_DIST = \
sysinfodata \
test-lib.sh \
vircaps2xmldata \
vboxsnapshotxmldata \
virsh-uriprecedence \
virfiledata \
virpcitestdata \
......@@ -236,6 +237,10 @@ if WITH_ESX
test_programs += esxutilstest
endif WITH_ESX
if WITH_VBOX
test_programs += vboxsnapshotxmltest
endif WITH_VBOX
if WITH_VMX
test_programs += vmx2xmltest xml2vmxtest
endif WITH_VMX
......@@ -619,6 +624,16 @@ else ! WITH_ESX
EXTRA_DIST += esxutilstest.c
endif ! WITH_ESX
if WITH_VBOX
vboxsnapshotxmltest_SOURCES = \
vboxsnapshotxmltest.c \
testutils.c testutils.h
vbox_LDADDS = ../src/libvirt_driver_vbox_impl.la
vboxsnapshotxmltest_LDADD = $(LDADDS) $(vbox_LDADDS)
else ! WITH_VBOX
EXTRA_DIST += vboxsnapshotxmltest.c
endif ! WITH_VBOX
if WITH_VMX
vmx2xmltest_SOURCES = \
vmx2xmltest.c \
......
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST.
Changes to this xml configuration should be made using Virtualbox
or other application using the libvirt API-->
<VirtualBox version="1.12-linux" xmlns="http://www.innotek.de/VirtualBox-settings">
<Machine uuid="{74864f52-a7b7-4172-a7a5-54b6f3e9cd21}" name="74864f52-a7b7-4172-a7a5-54b6f3e9cd21" currentSnapshot="{364c7314-b2d9-4fcf-b786-47b987449ef7}" snapshotFolder="/home/libvirt/vbox/74864f52-a7b7-4172-a7a5-54b6f3e9cd21/Snapshots" currentStateModified="false" OSType="Other" lastStateChange="2014-05-15T11:49:46Z">
<MediaRegistry>
<DVDImages/>
<FloppyImages/>
<HardDisks>
<HardDisk uuid="{105122e9-f6d2-42c1-9c11-c01699c79517}" location="/home/libvirt/vbox/74864f52-a7b7-4172-a7a5-54b6f3e9cd21/libvirtTest-disk1.vdi" format="VDI" type="Normal">
<HardDisk uuid="{a28723b5-8093-4548-bf87-e5fa4136f0a3}" location="/root/VirtualBox VMs/74864f52-a7b7-4172-a7a5-54b6f3e9cd21/fakedisk-0.vdi" format="VDI"/>
</HardDisk>
<HardDisk uuid="{f113fdf8-9750-4557-a8be-87fd02319071}" location="/home/libvirt/vbox/74864f52-a7b7-4172-a7a5-54b6f3e9cd21/libvirtTest-disk2.vdi" format="VDI" type="Normal">
<HardDisk uuid="{e1ff7f14-e6e5-40ac-8e05-8381a8ee5be9}" location="/root/VirtualBox VMs/74864f52-a7b7-4172-a7a5-54b6f3e9cd21/fakedisk-1.vdi" format="VDI"/>
</HardDisk>
</HardDisks>
</MediaRegistry>
<Hardware version="2">
<CPU count="1" hotplug="false">
<HardwareVirtEx enabled="true"/>
<HardwareVirtExNestedPaging enabled="true"/>
<HardwareVirtExVPID enabled="true"/>
<HardwareVirtExUX enabled="true"/>
<PAE enabled="false"/>
<LongMode enabled="true"/>
<HardwareVirtExLargePages enabled="false"/>
<HardwareVirtForce enabled="false"/>
</CPU>
<Memory RAMSize="192" PageFusion="false"/>
<HID Pointing="PS2Mouse" Keyboard="PS2Keyboard"/>
<HPET enabled="false"/>
<Chipset type="PIIX3"/>
<Boot>
<Order position="1" device="HardDisk"/>
<Order position="2" device="None"/>
<Order position="3" device="None"/>
<Order position="4" device="None"/>
</Boot>
<Display VRAMSize="8" monitorCount="1" accelerate3D="false" accelerate2DVideo="false"/>
<VideoCapture enabled="false" screens="18446744073709551615" horzRes="1024" vertRes="768" rate="512" fps="25"/>
<RemoteDisplay enabled="true" authType="Null" allowMultiConnection="true">
<VRDEProperties>
<Property name="TCP/Ports" value="5900"/>
</VRDEProperties>
</RemoteDisplay>
<BIOS>
<ACPI enabled="true"/>
<IOAPIC enabled="true"/>
<Logo fadeIn="true" fadeOut="true" displayTime="0"/>
<BootMenu mode="MessageAndMenu"/>
<TimeOffset value="0"/>
<PXEDebug enabled="false"/>
</BIOS>
<USB>
<Controllers/>
<DeviceFilters/>
</USB>
<Network>
<Adapter slot="0" enabled="true" MACAddress="0800272A589D" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
<InternalNetwork name="intnet"/>
<NATNetwork name="NatNetwork"/>
</DisabledModes>
<BridgedInterface name="hns0000000v"/>
</Adapter>
<Adapter slot="1" enabled="false" MACAddress="0800276B5197" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="2" enabled="false" MACAddress="080027A346C9" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="3" enabled="false" MACAddress="08002749A665" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="4" enabled="false" MACAddress="0800273246C6" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="5" enabled="false" MACAddress="080027B0B358" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="6" enabled="false" MACAddress="080027BF23E5" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="7" enabled="false" MACAddress="080027BEE078" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
</Network>
<UART>
<Port slot="0" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
<Port slot="1" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
</UART>
<LPT>
<Port slot="0" enabled="false" IOBase="0x378" IRQ="7"/>
<Port slot="1" enabled="false" IOBase="0x378" IRQ="7"/>
</LPT>
<AudioAdapter controller="AC97" driver="Pulse" enabled="false"/>
<RTC localOrUTC="local"/>
<SharedFolders/>
<Clipboard mode="Disabled"/>
<DragAndDrop mode="Disabled"/>
<IO>
<IoCache enabled="true" size="5"/>
<BandwidthGroups/>
</IO>
<HostPci>
<Devices/>
</HostPci>
<EmulatedUSB>
<CardReader enabled="false"/>
</EmulatedUSB>
<Guest memoryBalloonSize="0"/>
<GuestProperties/>
</Hardware>
<ExtraData>
<ExtraDataItem name="FRONTEND/Type" value="vrdp"/>
</ExtraData>
<StorageControllers>
<StorageController name="IDE Controller" type="PIIX4" PortCount="2" useHostIOCache="true" Bootable="true">
<AttachedDevice type="HardDisk" port="0" device="0">
<Image uuid="{a28723b5-8093-4548-bf87-e5fa4136f0a3}"/>
</AttachedDevice>
<AttachedDevice type="HardDisk" port="0" device="1">
<Image uuid="{e1ff7f14-e6e5-40ac-8e05-8381a8ee5be9}"/>
</AttachedDevice>
</StorageController>
<StorageController name="SATA Controller" type="AHCI" PortCount="30" useHostIOCache="false" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3"/>
<StorageController name="SCSI Controller" type="LsiLogic" PortCount="16" useHostIOCache="false" Bootable="true"/>
<StorageController name="Floppy Controller" type="I82078" PortCount="1" useHostIOCache="true" Bootable="true"/>
</StorageControllers>
<Snapshot uuid="{364c7314-b2d9-4fcf-b786-47b987449ef7}" name="15052014-115228" timeStamp="2014-05-15T09:52:29Z">
<Hardware version="2">
<CPU count="1" hotplug="false">
<HardwareVirtEx enabled="true"/>
<HardwareVirtExNestedPaging enabled="true"/>
<HardwareVirtExVPID enabled="true"/>
<HardwareVirtExUX enabled="true"/>
<PAE enabled="false"/>
<LongMode enabled="true"/>
<HardwareVirtExLargePages enabled="false"/>
<HardwareVirtForce enabled="false"/>
</CPU>
<Memory RAMSize="192" PageFusion="false"/>
<HID Pointing="PS2Mouse" Keyboard="PS2Keyboard"/>
<HPET enabled="false"/>
<Chipset type="PIIX3"/>
<Boot>
<Order position="1" device="HardDisk"/>
<Order position="2" device="None"/>
<Order position="3" device="None"/>
<Order position="4" device="None"/>
</Boot>
<Display VRAMSize="8" monitorCount="1" accelerate3D="false" accelerate2DVideo="false"/>
<VideoCapture enabled="false" screens="18446744073709551615" horzRes="1024" vertRes="768" rate="512" fps="25"/>
<RemoteDisplay enabled="true" authType="Null" allowMultiConnection="true">
<VRDEProperties>
<Property name="TCP/Ports" value="5900"/>
</VRDEProperties>
</RemoteDisplay>
<BIOS>
<ACPI enabled="true"/>
<IOAPIC enabled="true"/>
<Logo fadeIn="true" fadeOut="true" displayTime="0"/>
<BootMenu mode="MessageAndMenu"/>
<TimeOffset value="0"/>
<PXEDebug enabled="false"/>
</BIOS>
<USB>
<Controllers/>
<DeviceFilters/>
</USB>
<Network>
<Adapter slot="0" enabled="true" MACAddress="0800272A589D" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
<InternalNetwork name="intnet"/>
<NATNetwork name="NatNetwork"/>
</DisabledModes>
<BridgedInterface name="hns0000000v"/>
</Adapter>
<Adapter slot="1" enabled="false" MACAddress="0800276B5197" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="2" enabled="false" MACAddress="080027A346C9" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="3" enabled="false" MACAddress="08002749A665" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="4" enabled="false" MACAddress="0800273246C6" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="5" enabled="false" MACAddress="080027B0B358" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="6" enabled="false" MACAddress="080027BF23E5" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="7" enabled="false" MACAddress="080027BEE078" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
</Network>
<UART>
<Port slot="0" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
<Port slot="1" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
</UART>
<LPT>
<Port slot="0" enabled="false" IOBase="0x378" IRQ="7"/>
<Port slot="1" enabled="false" IOBase="0x378" IRQ="7"/>
</LPT>
<AudioAdapter controller="AC97" driver="Pulse" enabled="false"/>
<RTC localOrUTC="local"/>
<SharedFolders/>
<Clipboard mode="Disabled"/>
<DragAndDrop mode="Disabled"/>
<IO>
<IoCache enabled="true" size="5"/>
<BandwidthGroups/>
</IO>
<HostPci>
<Devices/>
</HostPci>
<EmulatedUSB>
<CardReader enabled="false"/>
</EmulatedUSB>
<Guest memoryBalloonSize="0"/>
<GuestProperties/>
</Hardware>
<StorageControllers>
<StorageController name="IDE Controller" type="PIIX4" PortCount="2" useHostIOCache="true" Bootable="true">
<AttachedDevice type="HardDisk" port="0" device="0">
<Image uuid="{105122e9-f6d2-42c1-9c11-c01699c79517}"/>
</AttachedDevice>
<AttachedDevice type="HardDisk" port="0" device="1">
<Image uuid="{f113fdf8-9750-4557-a8be-87fd02319071}"/>
</AttachedDevice>
</StorageController>
<StorageController name="SATA Controller" type="AHCI" PortCount="30" useHostIOCache="false" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3"/>
<StorageController name="SCSI Controller" type="LsiLogic" PortCount="16" useHostIOCache="false" Bootable="true"/>
<StorageController name="Floppy Controller" type="I82078" PortCount="1" useHostIOCache="true" Bootable="true"/>
</StorageControllers>
</Snapshot>
</Machine>
</VirtualBox>
此差异已折叠。
此差异已折叠。
此差异已折叠。
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST.
Changes to this xml configuration should be made using Virtualbox
or other application using the libvirt API-->
<VirtualBox version="1.12-linux" xmlns="http://www.innotek.de/VirtualBox-settings">
<Machine uuid="{74864f52-a7b7-4172-a7a5-54b6f3e9cd21}" name="74864f52-a7b7-4172-a7a5-54b6f3e9cd21" snapshotFolder="/home/libvirt/vbox/74864f52-a7b7-4172-a7a5-54b6f3e9cd21/Snapshots" currentStateModified="false" OSType="Other" lastStateChange="2014-05-15T11:49:46Z">
<MediaRegistry>
<DVDImages/>
<FloppyImages/>
<HardDisks>
<HardDisk uuid="{105122e9-f6d2-42c1-9c11-c01699c79517}" location="/home/libvirt/vbox/74864f52-a7b7-4172-a7a5-54b6f3e9cd21/libvirtTest-disk1.vdi" format="VDI" type="Normal"/>
<HardDisk uuid="{f113fdf8-9750-4557-a8be-87fd02319071}" location="/home/libvirt/vbox/74864f52-a7b7-4172-a7a5-54b6f3e9cd21/libvirtTest-disk2.vdi" format="VDI" type="Normal"/>
</HardDisks>
</MediaRegistry>
<Hardware version="2">
<CPU count="1" hotplug="false">
<HardwareVirtEx enabled="true"/>
<HardwareVirtExNestedPaging enabled="true"/>
<HardwareVirtExVPID enabled="true"/>
<HardwareVirtExUX enabled="true"/>
<PAE enabled="false"/>
<LongMode enabled="true"/>
<HardwareVirtExLargePages enabled="false"/>
<HardwareVirtForce enabled="false"/>
</CPU>
<Memory RAMSize="192" PageFusion="false"/>
<HID Pointing="PS2Mouse" Keyboard="PS2Keyboard"/>
<HPET enabled="false"/>
<Chipset type="PIIX3"/>
<Boot>
<Order position="1" device="HardDisk"/>
<Order position="2" device="None"/>
<Order position="3" device="None"/>
<Order position="4" device="None"/>
</Boot>
<Display VRAMSize="8" monitorCount="1" accelerate3D="false" accelerate2DVideo="false"/>
<VideoCapture enabled="false" screens="18446744073709551615" horzRes="1024" vertRes="768" rate="512" fps="25"/>
<RemoteDisplay enabled="true" authType="Null" allowMultiConnection="true">
<VRDEProperties>
<Property name="TCP/Ports" value="5900"/>
</VRDEProperties>
</RemoteDisplay>
<BIOS>
<ACPI enabled="true"/>
<IOAPIC enabled="true"/>
<Logo fadeIn="true" fadeOut="true" displayTime="0"/>
<BootMenu mode="MessageAndMenu"/>
<TimeOffset value="0"/>
<PXEDebug enabled="false"/>
</BIOS>
<USB>
<Controllers/>
<DeviceFilters/>
</USB>
<Network>
<Adapter slot="0" enabled="true" MACAddress="0800272A589D" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
<InternalNetwork name="intnet"/>
<NATNetwork name="NatNetwork"/>
</DisabledModes>
<BridgedInterface name="hns0000000v"/>
</Adapter>
<Adapter slot="1" enabled="false" MACAddress="0800276B5197" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="2" enabled="false" MACAddress="080027A346C9" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="3" enabled="false" MACAddress="08002749A665" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="4" enabled="false" MACAddress="0800273246C6" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="5" enabled="false" MACAddress="080027B0B358" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="6" enabled="false" MACAddress="080027BF23E5" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="7" enabled="false" MACAddress="080027BEE078" cable="true" speed="0" type="Am79C973">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
</Network>
<UART>
<Port slot="0" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
<Port slot="1" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
</UART>
<LPT>
<Port slot="0" enabled="false" IOBase="0x378" IRQ="7"/>
<Port slot="1" enabled="false" IOBase="0x378" IRQ="7"/>
</LPT>
<AudioAdapter controller="AC97" driver="Pulse" enabled="false"/>
<RTC localOrUTC="local"/>
<SharedFolders/>
<Clipboard mode="Disabled"/>
<DragAndDrop mode="Disabled"/>
<IO>
<IoCache enabled="true" size="5"/>
<BandwidthGroups/>
</IO>
<HostPci>
<Devices/>
</HostPci>
<EmulatedUSB>
<CardReader enabled="false"/>
</EmulatedUSB>
<Guest memoryBalloonSize="0"/>
<GuestProperties/>
</Hardware>
<ExtraData>
<ExtraDataItem name="FRONTEND/Type" value="vrdp"/>
</ExtraData>
<StorageControllers>
<StorageController name="IDE Controller" type="PIIX4" PortCount="2" useHostIOCache="true" Bootable="true">
<AttachedDevice type="HardDisk" port="0" device="0">
<Image uuid="{105122e9-f6d2-42c1-9c11-c01699c79517}"/>
</AttachedDevice>
<AttachedDevice type="HardDisk" port="0" device="1">
<Image uuid="{f113fdf8-9750-4557-a8be-87fd02319071}"/>
</AttachedDevice>
</StorageController>
<StorageController name="SATA Controller" type="AHCI" PortCount="30" useHostIOCache="false" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3"/>
<StorageController name="SCSI Controller" type="LsiLogic" PortCount="16" useHostIOCache="false" Bootable="true"/>
<StorageController name="Floppy Controller" type="I82078" PortCount="1" useHostIOCache="true" Bootable="true"/>
</StorageControllers>
</Machine>
</VirtualBox>
#include <config.h>
#include "testutils.h"
#ifdef WITH_VBOX
# include <stdio.h>
# include <stdlib.h>
# include <regex.h>
# include "vbox/vbox_snapshot_conf.h"
# define VIR_FROM_THIS VIR_FROM_NONE
static const char *testSnapshotXMLVariableLineRegexStr =
"lastStateChange=[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z";
regex_t *testSnapshotXMLVariableLineRegex = NULL;
static char *
testFilterXML(char *xml)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
char **xmlLines = NULL;
char **xmlLine;
char *ret = NULL;
if (!(xmlLines = virStringSplit(xml, "\n", 0))) {
VIR_FREE(xml);
goto cleanup;
}
VIR_FREE(xml);
for (xmlLine = xmlLines; *xmlLine; xmlLine++) {
if (regexec(testSnapshotXMLVariableLineRegex,
*xmlLine, 0, NULL, 0) == 0)
continue;
virBufferStrcat(&buf, *xmlLine, "\n", NULL);
}
if (virBufferError(&buf)) {
virReportOOMError();
goto cleanup;
}
ret = virBufferContentAndReset(&buf);
cleanup:
virBufferFreeAndReset(&buf);
virStringFreeList(xmlLines);
return ret;
}
static int
testCompareXMLtoXMLFiles(const char *xml)
{
char *xmlData = NULL;
char *actual = NULL;
char *pathResult = NULL;
int ret = -1;
virVBoxSnapshotConfMachinePtr machine = NULL;
if (virAsprintf(&pathResult, "%s/vboxsnapshotxmldata/testResult.vbox",
abs_srcdir) < 0)
return -1;
if (virtTestLoadFile(xml, &xmlData) < 0)
goto fail;
if (!(machine = virVBoxSnapshotConfLoadVboxFile(xml, (char*)"")))
goto fail;
if (virVBoxSnapshotConfSaveVboxFile(machine, pathResult) < 0)
goto fail;
if (virtTestLoadFile(pathResult, &actual) < 0)
goto fail;
if (unlink(pathResult) < 0)
goto fail;
if (!(actual = testFilterXML(actual)))
goto fail;
if (!(xmlData = testFilterXML(xmlData)))
goto fail;
if (STRNEQ(actual, xmlData)) {
virtTestDifference(stderr, xmlData, actual);
goto fail;
}
ret = 0;
fail:
VIR_FREE(xmlData);
VIR_FREE(actual);
virVBoxSnapshotConfMachineFree(machine);
VIR_FREE(pathResult);
return ret;
}
static int
testCompareXMLToXMLHelper(const void *data)
{
int result = -1;
char *xml = NULL;
if (virAsprintf(&xml, "%s/vboxsnapshotxmldata/%s.vbox",
abs_srcdir, (const char*)data) < 0)
return -1;
result = testCompareXMLtoXMLFiles(xml);
VIR_FREE(xml);
return result;
}
static int
mymain(void)
{
int ret = 0;
if (VIR_ALLOC(testSnapshotXMLVariableLineRegex) < 0)
goto cleanup;
if (regcomp(testSnapshotXMLVariableLineRegex,
testSnapshotXMLVariableLineRegexStr,
REG_EXTENDED | REG_NOSUB) != 0) {
ret = -1;
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
"failed to compile test regex");
goto cleanup;
}
# define DO_TEST(name) \
if (virtTestRun("VBox Snapshot XML-2-XML " name, \
testCompareXMLToXMLHelper, (name)) < 0) \
ret = -1
DO_TEST("2disks-nosnap");
DO_TEST("2disks-1snap");
DO_TEST("2disks-2snap");
DO_TEST("2disks-3snap");
DO_TEST("2disks-3snap-brother");
cleanup:
if (testSnapshotXMLVariableLineRegex)
regfree(testSnapshotXMLVariableLineRegex);
VIR_FREE(testSnapshotXMLVariableLineRegex);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
VIRT_TEST_MAIN(mymain)
#else
int main(void)
{
return EXIT_AM_SKIP;
}
#endif /*WITH_VBOX*/
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册