mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 13:05:27 +00:00
xen: Move xenParseSxprSound to xen_common
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
4fbecf4432
commit
228f7ed148
@ -6,7 +6,6 @@
|
||||
xenGetDomIdFromSxpr;
|
||||
xenGetDomIdFromSxprString;
|
||||
xenParseSxprChar;
|
||||
xenParseSxprSound;
|
||||
xenParseSxprVifRate;
|
||||
|
||||
# xenconfig/xen_xm.h
|
||||
|
@ -1137,6 +1137,87 @@ xenParseVifList(virConfPtr conf, virDomainDefPtr def, const char *vif_typename)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* xenParseSxprSound:
|
||||
* @def: the domain config
|
||||
* @str: comma separated list of sound models
|
||||
*
|
||||
* This parses out sound devices from the domain S-expression
|
||||
*
|
||||
* Returns 0 if successful or -1 if failed.
|
||||
*/
|
||||
static int
|
||||
xenParseSxprSound(virDomainDefPtr def,
|
||||
const char *str)
|
||||
{
|
||||
if (STREQ(str, "all")) {
|
||||
size_t i;
|
||||
|
||||
/*
|
||||
* Special compatibility code for Xen with a bogus
|
||||
* sound=all in config.
|
||||
*
|
||||
* NB deliberately, don't include all possible
|
||||
* sound models anymore, just the 2 that were
|
||||
* historically present in Xen's QEMU.
|
||||
*
|
||||
* ie just es1370 + sb16.
|
||||
*
|
||||
* Hence use of MODEL_ES1370 + 1, instead of MODEL_LAST
|
||||
*/
|
||||
|
||||
if (VIR_ALLOC_N(def->sounds,
|
||||
VIR_DOMAIN_SOUND_MODEL_ES1370 + 1) < 0)
|
||||
return -1;
|
||||
|
||||
|
||||
for (i = 0; i < (VIR_DOMAIN_SOUND_MODEL_ES1370 + 1); i++) {
|
||||
virDomainSoundDefPtr sound;
|
||||
if (VIR_ALLOC(sound) < 0)
|
||||
return -1;
|
||||
sound->model = i;
|
||||
def->sounds[def->nsounds++] = sound;
|
||||
}
|
||||
} else {
|
||||
char model[10];
|
||||
const char *offset = str, *offset2;
|
||||
|
||||
do {
|
||||
int len;
|
||||
virDomainSoundDefPtr sound;
|
||||
offset2 = strchr(offset, ',');
|
||||
if (offset2)
|
||||
len = (offset2 - offset);
|
||||
else
|
||||
len = strlen(offset);
|
||||
if (virStrncpy(model, offset, len, sizeof(model)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Sound model %s too big for destination"),
|
||||
offset);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (VIR_ALLOC(sound) < 0)
|
||||
return -1;
|
||||
|
||||
if ((sound->model = virDomainSoundModelTypeFromString(model)) < 0) {
|
||||
VIR_FREE(sound);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (VIR_APPEND_ELEMENT(def->sounds, def->nsounds, sound) < 0) {
|
||||
virDomainSoundDefFree(sound);
|
||||
return -1;
|
||||
}
|
||||
|
||||
offset = offset2 ? offset2 + 1 : NULL;
|
||||
} while (offset);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
xenParseEmulatedDevices(virConfPtr conf, virDomainDefPtr def)
|
||||
{
|
||||
|
@ -270,84 +270,3 @@ xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec)
|
||||
VIR_FREE(trate);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* xenParseSxprSound:
|
||||
* @def: the domain config
|
||||
* @str: comma separated list of sound models
|
||||
*
|
||||
* This parses out sound devices from the domain S-expression
|
||||
*
|
||||
* Returns 0 if successful or -1 if failed.
|
||||
*/
|
||||
int
|
||||
xenParseSxprSound(virDomainDefPtr def,
|
||||
const char *str)
|
||||
{
|
||||
if (STREQ(str, "all")) {
|
||||
size_t i;
|
||||
|
||||
/*
|
||||
* Special compatibility code for Xen with a bogus
|
||||
* sound=all in config.
|
||||
*
|
||||
* NB deliberately, don't include all possible
|
||||
* sound models anymore, just the 2 that were
|
||||
* historically present in Xen's QEMU.
|
||||
*
|
||||
* ie just es1370 + sb16.
|
||||
*
|
||||
* Hence use of MODEL_ES1370 + 1, instead of MODEL_LAST
|
||||
*/
|
||||
|
||||
if (VIR_ALLOC_N(def->sounds,
|
||||
VIR_DOMAIN_SOUND_MODEL_ES1370 + 1) < 0)
|
||||
return -1;
|
||||
|
||||
|
||||
for (i = 0; i < (VIR_DOMAIN_SOUND_MODEL_ES1370 + 1); i++) {
|
||||
virDomainSoundDefPtr sound;
|
||||
if (VIR_ALLOC(sound) < 0)
|
||||
return -1;
|
||||
sound->model = i;
|
||||
def->sounds[def->nsounds++] = sound;
|
||||
}
|
||||
} else {
|
||||
char model[10];
|
||||
const char *offset = str, *offset2;
|
||||
|
||||
do {
|
||||
int len;
|
||||
virDomainSoundDefPtr sound;
|
||||
offset2 = strchr(offset, ',');
|
||||
if (offset2)
|
||||
len = (offset2 - offset);
|
||||
else
|
||||
len = strlen(offset);
|
||||
if (virStrncpy(model, offset, len, sizeof(model)) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Sound model %s too big for destination"),
|
||||
offset);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (VIR_ALLOC(sound) < 0)
|
||||
return -1;
|
||||
|
||||
if ((sound->model = virDomainSoundModelTypeFromString(model)) < 0) {
|
||||
VIR_FREE(sound);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (VIR_APPEND_ELEMENT(def->sounds, def->nsounds, sound) < 0) {
|
||||
virDomainSoundDefFree(sound);
|
||||
return -1;
|
||||
}
|
||||
|
||||
offset = offset2 ? offset2 + 1 : NULL;
|
||||
} while (offset);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -31,8 +31,6 @@
|
||||
int xenGetDomIdFromSxprString(const char *sexpr, int *id);
|
||||
int xenGetDomIdFromSxpr(const struct sexpr *root, int *id);
|
||||
|
||||
int xenParseSxprSound(virDomainDefPtr def, const char *str);
|
||||
|
||||
virDomainChrDefPtr xenParseSxprChar(const char *value, const char *tty);
|
||||
|
||||
int xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec);
|
||||
|
Loading…
x
Reference in New Issue
Block a user