968
/* virDomainChrSourceDefIsEqual:
972
* Compares source and target if they contain
973
* the same information.
976
virDomainChrSourceDefIsEqual(const virDomainChrSourceDef *src,
977
const virDomainChrSourceDef *tgt)
979
if (tgt->type != src->type)
983
case VIR_DOMAIN_CHR_TYPE_PTY:
984
case VIR_DOMAIN_CHR_TYPE_DEV:
985
case VIR_DOMAIN_CHR_TYPE_FILE:
986
case VIR_DOMAIN_CHR_TYPE_PIPE:
987
return STREQ_NULLABLE(src->data.file.path, tgt->data.file.path);
989
case VIR_DOMAIN_CHR_TYPE_UDP:
990
return STREQ_NULLABLE(src->data.udp.bindHost, tgt->data.udp.bindHost) &&
991
STREQ_NULLABLE(src->data.udp.bindService, tgt->data.udp.bindService) &&
992
STREQ_NULLABLE(src->data.udp.connectHost, tgt->data.udp.connectHost) &&
993
STREQ_NULLABLE(src->data.udp.connectService, tgt->data.udp.connectService);
995
case VIR_DOMAIN_CHR_TYPE_TCP:
996
return src->data.tcp.listen == tgt->data.tcp.listen &&
997
src->data.tcp.protocol == tgt->data.tcp.protocol &&
998
STREQ_NULLABLE(src->data.tcp.host, tgt->data.tcp.host) &&
999
STREQ_NULLABLE(src->data.tcp.service, tgt->data.tcp.service);
1001
case VIR_DOMAIN_CHR_TYPE_UNIX:
1002
return src->data.nix.listen == tgt->data.nix.listen &&
1003
STREQ_NULLABLE(src->data.nix.path, tgt->data.nix.path);
1006
case VIR_DOMAIN_CHR_TYPE_VC:
1007
case VIR_DOMAIN_CHR_TYPE_STDIO:
1008
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
1013
/* This should happen only on new,
1014
* yet unhandled type */
968
1019
void virDomainChrDefFree(virDomainChrDefPtr def)
7252
7304
* So if we see that this console device should
7253
7305
* be a serial device, then we move the config
7254
7306
* over to def->serials[0] (or discard it if
7255
* that already exists
7307
* that already exists). However, given console
7308
* can already be filled with aliased data of
7309
* def->serials[0]. Keep it then.
7257
7311
* We then fill def->consoles[0] with a stub
7258
7312
* just so we get sequencing correct for consoles
7269
7323
/* Either discard or move this chr to the serial config */
7270
7324
if (def->nserials != 0) {
7271
virDomainChrDefFree(chr);
7325
if (virDomainChrSourceDefIsEqual(&def->serials[0]->source,
7327
/* Alias to def->serial[0]. Skip it */
7328
create_stub = false;
7330
virDomainChrDefFree(chr);
7273
7333
if (VIR_ALLOC_N(def->serials, 1) < 0) {
7274
7334
virDomainChrDefFree(chr);
7280
7340
chr->target.port = 0;
7283
/* And create a stub placeholder */
7284
if (VIR_ALLOC(chr) < 0)
7286
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
7287
chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
7344
/* And create a stub placeholder */
7345
if (VIR_ALLOC(chr) < 0)
7347
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
7348
chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
7290
7352
chr->target.port = i;