mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
qemu: cold-unplug of sound
With this patch users can cold unplug some sound devices. use "virsh detach-device vm sound.xml --config" command. Reviewed-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Jidong Xia <xiajidong@cmss.chinamobile.com>
This commit is contained in:
parent
fda14dd782
commit
863c0d8e8d
@ -2753,6 +2753,14 @@ void virDomainSoundDefFree(virDomainSoundDefPtr def)
|
||||
VIR_FREE(def);
|
||||
}
|
||||
|
||||
virDomainSoundDefPtr
|
||||
virDomainSoundDefRemove(virDomainDefPtr def, size_t idx)
|
||||
{
|
||||
virDomainSoundDefPtr ret = def->sounds[idx];
|
||||
VIR_DELETE_ELEMENT(def->sounds, idx, def->nsounds);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def)
|
||||
{
|
||||
if (!def)
|
||||
@ -14554,6 +14562,46 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xmlopt,
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
virDomainSoundDefEquals(const virDomainSoundDef *a,
|
||||
const virDomainSoundDef *b)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (a->model != b->model)
|
||||
return false;
|
||||
|
||||
if (a->ncodecs != b->ncodecs)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < a->ncodecs; i++) {
|
||||
if (a->codecs[i]->type != b->codecs[i]->type)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (a->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
|
||||
!virDomainDeviceInfoAddressIsEqual(&a->info, &b->info))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
ssize_t
|
||||
virDomainSoundDefFind(const virDomainDef *def,
|
||||
const virDomainSoundDef *sound)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < def->nsounds; i++) {
|
||||
if (virDomainSoundDefEquals(sound, def->sounds[i]))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static virDomainWatchdogDefPtr
|
||||
virDomainWatchdogDefParseXML(virDomainXMLOptionPtr xmlopt,
|
||||
xmlNodePtr node,
|
||||
|
@ -2883,7 +2883,10 @@ void virDomainChrDefFree(virDomainChrDefPtr def);
|
||||
int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
|
||||
virDomainChrSourceDefPtr src);
|
||||
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
|
||||
ssize_t virDomainSoundDefFind(const virDomainDef *def,
|
||||
const virDomainSoundDef *sound);
|
||||
void virDomainSoundDefFree(virDomainSoundDefPtr def);
|
||||
virDomainSoundDefPtr virDomainSoundDefRemove(virDomainDefPtr def, size_t idx);
|
||||
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
|
||||
void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
|
||||
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
|
||||
|
@ -578,7 +578,9 @@ virDomainSmartcardTypeFromString;
|
||||
virDomainSmartcardTypeToString;
|
||||
virDomainSmbiosModeTypeFromString;
|
||||
virDomainSmbiosModeTypeToString;
|
||||
virDomainSoundDefFind;
|
||||
virDomainSoundDefFree;
|
||||
virDomainSoundDefRemove;
|
||||
virDomainSoundModelTypeFromString;
|
||||
virDomainSoundModelTypeToString;
|
||||
virDomainStartupPolicyTypeFromString;
|
||||
|
@ -8308,6 +8308,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
|
||||
{
|
||||
virDomainDiskDefPtr disk, det_disk;
|
||||
virDomainNetDefPtr net;
|
||||
virDomainSoundDefPtr sound;
|
||||
virDomainHostdevDefPtr hostdev, det_hostdev;
|
||||
virDomainLeaseDefPtr lease, det_lease;
|
||||
virDomainControllerDefPtr cont, det_cont;
|
||||
@ -8336,6 +8337,16 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
|
||||
virDomainNetDefFree(virDomainNetRemove(vmdef, idx));
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_SOUND:
|
||||
sound = dev->data.sound;
|
||||
if ((idx = virDomainSoundDefFind(vmdef, sound)) < 0) {
|
||||
virReportError(VIR_ERR_DEVICE_MISSING, "%s",
|
||||
_("device not present in domain configuration"));
|
||||
return -1;
|
||||
}
|
||||
virDomainSoundDefFree(virDomainSoundDefRemove(vmdef, idx));
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_HOSTDEV: {
|
||||
hostdev = dev->data.hostdev;
|
||||
if ((idx = virDomainHostdevFind(vmdef, hostdev, &det_hostdev)) < 0) {
|
||||
@ -8466,7 +8477,6 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
|
||||
vmdef->vsock = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_SOUND:
|
||||
case VIR_DOMAIN_DEVICE_VIDEO:
|
||||
case VIR_DOMAIN_DEVICE_GRAPHICS:
|
||||
case VIR_DOMAIN_DEVICE_HUB:
|
||||
|
Loading…
Reference in New Issue
Block a user