Bug 1152427

Summary: Too small xml size limit for virsh restore command
Product: [Community] Virtualization Tools Reporter: Reno <reno.gan>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: pkrempa, rbalakri
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-14 08:29:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Reno 2014-10-14 07:12:15 UTC
Description of problem:
When use "virsh restore vm.img --xml vm.xml" to restore vm, if vm.xml size is over 8192, command will fail with error "Value too large for defined data type"

Version-Release number of selected component (if applicable):
all versions

How reproducible:
restore a vm with "virsh  restore vm.img --xml vm.xml", while vm.xml size is over 8192. 

Actual results:
command will fail with error "Value too large for defined data type"

Expected results:
command succeeds

Additional info:
in tools/virsh-domain.c:4768,virFileReadAll(xmlfile, 8192, &xml) < 0,the second parameter is too small, shall use "VSH_MAX_XML_FILE" constant instead.

Comment 1 Peter Krempa 2014-10-14 08:12:11 UTC
I've proposed a fix upstream:

http://www.redhat.com/archives/libvir-list/2014-October/msg00427.html

Comment 2 Peter Krempa 2014-10-14 08:29:52 UTC
Fixed upstream:

commit 4d1852c48541a29e3c47caf0f2b801dfcb6579db
Author: Peter Krempa <pkrempa>
Date:   Tue Oct 14 10:04:31 2014 +0200

    virsh: domain: Use global constant for XML file size limit
    
    Few places still used hardcoded limit for maximum XML size for commands
    that accept XML files. The hardcoded limits ranged from 8k to 1M. Use
    VSH_MAX_XML_FILE to express this limit in a unified way. This will bump
    the limit for the commands that used hardcoded string lengths to 10M.

The patch will be part of the next release.