Skip to content

Commit d0ba2b8

Browse files
committed
API: bugref:11116 Sanitize imported data from OVA/OVF by removing serial port settings if they are directed to host raw file.
svn:sync-xref-src-repo-rev: r174528
1 parent 4351657 commit d0ba2b8

3 files changed

Lines changed: 37 additions & 4 deletions

File tree

include/VBox/settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,7 @@ class MachineConfigFile : public ConfigFileBase
15851585
void buildMachineXML(xml::ElementNode &elmMachine,
15861586
uint32_t fl,
15871587
std::list<xml::ElementNode*> *pllElementsWithUuidAttributes);
1588-
1588+
void sanitizeImportedSerialPorts();
15891589
static bool isAudioDriverAllowedOnThisHost(AudioDriverType_T enmDrvType);
15901590
static AudioDriverType_T getHostDefaultAudioDriver();
15911591

src/VBox/Main/src-server/ApplianceImplImport.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Id: ApplianceImplImport.cpp 112403 2026-01-11 19:29:08Z knut.osmundsen@oracle.com $ */
1+
/* $Id: ApplianceImplImport.cpp 114692 2026-07-14 10:57:00Z serkan.bayraktar@oracle.com $ */
22
/** @file
33
* IAppliance and IVirtualSystem COM class implementations.
44
*/
@@ -381,7 +381,23 @@ HRESULT Appliance::interpret()
381381
/* The NVRAM file does not have a <vbox:Machine> entry so we only need to check the OVF details. */
382382
if (vsysThis.strNvramPath.isNotEmpty())
383383
pNewDesc->i_addEntry(VirtualSystemDescriptionType_NVRAM, "", vsysThis.strNvramPath, vsysThis.strNvramPath);
384-
384+
/* Check if any of the serial ports is configured with mode raw file. */
385+
if (vsysThis.pelmVBoxMachine)
386+
{
387+
settings::SerialPortsList const &llSerialPorts =
388+
pNewDesc->m->pConfig->hardwareMachine.llSerialPorts;
389+
for (settings::SerialPortsList::const_iterator port_it = llSerialPorts.begin();
390+
port_it != llSerialPorts.end();
391+
++port_it)
392+
{
393+
if (port_it->portMode == PortMode_RawFile)
394+
{
395+
i_addWarning(tr("Virtual appliance \"%s\" was configured with serial port(s) "
396+
"with \"raw file\" mode. These setting will not be imported"), vsysThis.strName.c_str());
397+
break;
398+
}
399+
}
400+
}
385401
/* Audio */
386402
Utf8Str strSoundCard;
387403
Utf8Str strSoundCardOrig;
@@ -6117,6 +6133,7 @@ void Appliance::i_importVBoxMachine(ComObjPtr<VirtualSystemDescription> &vsdescT
61176133
ComObjPtr<Machine> pNewMachine;
61186134
hrc = pNewMachine.createObject();
61196135
if (FAILED(hrc)) throw hrc;
6136+
config.sanitizeImportedSerialPorts();
61206137

61216138
// this magic constructor fills the new machine object with the MachineConfig
61226139
// instance that we created from the vbox:Machine

src/VBox/Main/xml/Settings.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Id: Settings.cpp 114362 2026-06-15 18:31:38Z andreas.loeffler@oracle.com $ */
1+
/* $Id: Settings.cpp 114692 2026-07-14 10:57:00Z serkan.bayraktar@oracle.com $ */
22
/** @file
33
* Settings File Manipulation API.
44
*
@@ -9696,6 +9696,22 @@ bool MachineConfigFile::isAudioDriverAllowedOnThisHost(AudioDriverType_T enmDrvT
96969696
return false;
96979697
}
96989698

9699+
void MachineConfigFile::sanitizeImportedSerialPorts()
9700+
{
9701+
for (SerialPortsList::iterator it = hardwareMachine.llSerialPorts.begin();
9702+
it != hardwareMachine.llSerialPorts.end();
9703+
++it)
9704+
{
9705+
SerialPort &port = *it;
9706+
if (port.portMode == PortMode_RawFile)
9707+
{
9708+
port.portMode = PortMode_Disconnected;
9709+
port.fEnabled = false;
9710+
port.strPath.setNull();
9711+
}
9712+
}
9713+
}
9714+
96999715
/**
97009716
* Called from write() before calling ConfigFileBase::createStubDocument().
97019717
* This adjusts the settings version in m->sv if incompatible settings require

0 commit comments

Comments
 (0)