mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
virDomainChrSourceDefCopy: Copy more struct members
The aim of virDomainChrSourceDefCopy() is to make a deep copy of given virDomainChrSourceDef. However, some types were not copied at all (VIR_DOMAIN_CHR_TYPE_SPICEVMC and VIR_DOMAIN_CHR_TYPE_SPICEPORT) and some members weren't copied either (@logfile, @logappend). After this, there are still some members that are not copied (seclabels and private data), but the sole caller qemuProcessFindCharDevicePTYsMonitor() doesn't seem to care. Therefore, just document this behavior so that future user is aware. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
3de95c3d51
commit
8af76c3764
@ -2732,8 +2732,9 @@ virDomainChrSourceDefClear(virDomainChrSourceDef *def)
|
||||
VIR_FREE(def->logfile);
|
||||
}
|
||||
|
||||
/* Deep copies the contents of src into dest. Return -1 and report
|
||||
* error on failure. */
|
||||
/* Almost deep copies the contents of src into dest. Some parts are not copied
|
||||
* though.
|
||||
* Returns -1 and report error on failure. */
|
||||
int
|
||||
virDomainChrSourceDefCopy(virDomainChrSourceDef *dest,
|
||||
virDomainChrSourceDef *src)
|
||||
@ -2743,7 +2744,11 @@ virDomainChrSourceDefCopy(virDomainChrSourceDef *dest,
|
||||
|
||||
virDomainChrSourceDefClear(dest);
|
||||
|
||||
switch (src->type) {
|
||||
dest->type = src->type;
|
||||
dest->logfile = g_strdup(src->logfile);
|
||||
dest->logappend = src->logappend;
|
||||
|
||||
switch ((virDomainChrType)src->type) {
|
||||
case VIR_DOMAIN_CHR_TYPE_FILE:
|
||||
case VIR_DOMAIN_CHR_TYPE_PTY:
|
||||
case VIR_DOMAIN_CHR_TYPE_DEV:
|
||||
@ -2783,9 +2788,21 @@ virDomainChrSourceDefCopy(virDomainChrSourceDef *dest,
|
||||
dest->data.nmdm.slave = g_strdup(src->data.nmdm.slave);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
dest->type = src->type;
|
||||
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
|
||||
dest->data.spicevmc = src->data.spicevmc;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
|
||||
dest->data.spiceport.channel = g_strdup(src->data.spiceport.channel);
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_NULL:
|
||||
case VIR_DOMAIN_CHR_TYPE_VC:
|
||||
case VIR_DOMAIN_CHR_TYPE_STDIO:
|
||||
case VIR_DOMAIN_CHR_TYPE_LAST:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user