virsh: Move 'virshDomainBlockJobToString' to virsh-util

The helper function is used in virshBlockJobInfo and also in the
callbacks of cmdEvent. Upcoming patch is going to move out the event
code into a helper so this needs to be in a shared place.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-02-21 16:12:59 +01:00
parent bf9de8cb51
commit c704d27d4a
3 changed files with 24 additions and 19 deletions

View File

@ -2614,25 +2614,6 @@ static const vshCmdOptDef opts_blockjob[] = {
{.name = NULL}
};
VIR_ENUM_DECL(virshDomainBlockJob);
VIR_ENUM_IMPL(virshDomainBlockJob,
VIR_DOMAIN_BLOCK_JOB_TYPE_LAST,
N_("Unknown job"),
N_("Block Pull"),
N_("Block Copy"),
N_("Block Commit"),
N_("Active Block Commit"),
N_("Backup"),
);
static const char *
virshDomainBlockJobToString(int type)
{
const char *str = virshDomainBlockJobTypeToString(type);
return str ? _(str) : _("Unknown job");
}
static bool
virshBlockJobInfo(vshControl *ctl,
virDomainPtr dom,

View File

@ -418,3 +418,22 @@ virshDomainGetXML(vshControl *ctl,
return ret;
}
VIR_ENUM_IMPL(virshDomainBlockJob,
VIR_DOMAIN_BLOCK_JOB_TYPE_LAST,
N_("Unknown job"),
N_("Block Pull"),
N_("Block Copy"),
N_("Block Commit"),
N_("Active Block Commit"),
N_("Backup"),
);
const char *
virshDomainBlockJobToString(int type)
{
const char *str = virshDomainBlockJobTypeToString(type);
return str ? _(str) : _("Unknown job");
}

View File

@ -151,3 +151,8 @@ virshDomainGetXML(vshControl *ctl,
xmlXPathContextPtr *ctxt)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4)
ATTRIBUTE_NONNULL(5) G_GNUC_WARN_UNUSED_RESULT;
VIR_ENUM_DECL(virshDomainBlockJob);
const char *
virshDomainBlockJobToString(int type);